diff --git a/package-lock.json b/package-lock.json index ef098a04..0879767c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,16 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "acorn": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz", @@ -1141,8 +1151,8 @@ "integrity": "sha512-8od6g684Fhi5Vpp4ABRv/RBsW1AY6wSHbJHEK6FGTv+8jvAAnlABniZu/FVmX9TcirkHepaEsa1QGkRvbg0CKw==", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.2.0", @@ -2329,16 +2339,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -3430,15 +3430,6 @@ "yargs": "8.0.2" } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -3450,6 +3441,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", diff --git a/src/writeFile.js b/src/writeFile.js index 3abff673..8f8bffc8 100644 --- a/src/writeFile.js +++ b/src/writeFile.js @@ -67,13 +67,17 @@ export default function writeFile(globalRef, pattern, file) { } if (!copyUnmodified && - written[file.absoluteFrom] && written[file.absoluteFrom][hash]) { + written[file.absoluteFrom] && + written[file.absoluteFrom]['hash'] === hash && + written[file.absoluteFrom]['webpackTo'] === file.webpackTo + ) { info(`skipping '${file.webpackTo}', because it hasn't changed`); return; } else { debug(`added ${hash} to written tracking for '${file.absoluteFrom}'`); written[file.absoluteFrom] = { - [hash]: true + hash: hash, + webpackTo: file.webpackTo }; } diff --git a/tests/index.js b/tests/index.js index ccd53ae0..b11263c3 100644 --- a/tests/index.js +++ b/tests/index.js @@ -820,6 +820,24 @@ describe('apply function', () => { .then(done) .catch(done); }); + + it('same file to multiple targets', (done) => { + runEmit({ + expectedAssetKeys: [ + 'first/file.txt', + 'second/file.txt' + ], + patterns: [{ + from: 'file.txt', + to: 'first/file.txt' + }, { + from: 'file.txt', + to: 'second/file.txt' + }] + }) + .then(done) + .catch(done); + }); }); describe('with directory in from', () => {