Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle [contenthash] as template #328

Merged
merged 2 commits into from Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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