diff --git a/src/preProcessPattern.js b/src/preProcessPattern.js index bf38bef1..ad7618ab 100644 --- a/src/preProcessPattern.js +++ b/src/preProcessPattern.js @@ -7,7 +7,7 @@ import isObject from './utils/isObject'; import { stat } from './utils/promisify'; // https://www.debuggex.com/r/VH2yS2mvJOitiyr3 -const isTemplateLike = /(\[ext\])|(\[name\])|(\[path\])|(\[folder\])|(\[emoji(:\d+)?\])|(\[(\w+:)?hash(:\w+)?(:\d+)?\])|(\[\d+\])/; +const isTemplateLike = /(\[ext\])|(\[name\])|(\[path\])|(\[folder\])|(\[emoji(:\d+)?\])|(\[(\w+:)?(hash|contenthash)(:\w+)?(:\d+)?\])|(\[\d+\])/; /* eslint-disable no-param-reassign */ diff --git a/test/CopyPlugin.test.js b/test/CopyPlugin.test.js index db6601f3..1733ff13 100644 --- a/test/CopyPlugin.test.js +++ b/test/CopyPlugin.test.js @@ -1184,6 +1184,20 @@ describe('apply function', () => { .catch(done); }); + it('allows pattern to contain contenthash', (done) => { + runEmit({ + expectedAssetKeys: ['directory/22af64.txt'], + patterns: [ + { + from: 'directory/directoryfile.txt', + to: 'directory/[contenthash:6].txt', + }, + ], + }) + .then(done) + .catch(done); + }); + it('transform with promise', (done) => { runEmit({ expectedAssetKeys: ['file.txt'],