Skip to content

Commit

Permalink
fix: handle [contenthash] as template (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Feb 15, 2019
1 parent 6ea72d7 commit 61dfe52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/preProcessPattern.js
Expand Up @@ -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 */

Expand Down
14 changes: 14 additions & 0 deletions test/CopyPlugin.test.js
Expand Up @@ -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'],
Expand Down

0 comments on commit 61dfe52

Please sign in to comment.