Skip to content

Commit 61dfe52

Browse files
authoredFeb 15, 2019
fix: handle [contenthash] as template (#328)
1 parent 6ea72d7 commit 61dfe52

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
 

‎src/preProcessPattern.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import isObject from './utils/isObject';
77
import { stat } from './utils/promisify';
88

99
// https://www.debuggex.com/r/VH2yS2mvJOitiyr3
10-
const isTemplateLike = /(\[ext\])|(\[name\])|(\[path\])|(\[folder\])|(\[emoji(:\d+)?\])|(\[(\w+:)?hash(:\w+)?(:\d+)?\])|(\[\d+\])/;
10+
const isTemplateLike = /(\[ext\])|(\[name\])|(\[path\])|(\[folder\])|(\[emoji(:\d+)?\])|(\[(\w+:)?(hash|contenthash)(:\w+)?(:\d+)?\])|(\[\d+\])/;
1111

1212
/* eslint-disable no-param-reassign */
1313

‎test/CopyPlugin.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,20 @@ describe('apply function', () => {
11841184
.catch(done);
11851185
});
11861186

1187+
it('allows pattern to contain contenthash', (done) => {
1188+
runEmit({
1189+
expectedAssetKeys: ['directory/22af64.txt'],
1190+
patterns: [
1191+
{
1192+
from: 'directory/directoryfile.txt',
1193+
to: 'directory/[contenthash:6].txt',
1194+
},
1195+
],
1196+
})
1197+
.then(done)
1198+
.catch(done);
1199+
});
1200+
11871201
it('transform with promise', (done) => {
11881202
runEmit({
11891203
expectedAssetKeys: ['file.txt'],

0 commit comments

Comments
 (0)
Please sign in to comment.