diff --git a/README.md b/README.md index faf44edf..1b7bc7ae 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ module.exports = { | Name | Type | Default | Description | | :-------------------------------: | :-------------------: | :---------------------------------------------: | :---------------------------------------------------------------------------------------------------- | | [`from`](#from) | `{String\|Object}` | `undefined` | Glob or path from where we сopy files. | -| [`to`](#to) | `{String}` | `undefined` | Output path. | +| [`to`](#to) | `{String}` | `compiler.options.output` | Output path. | | [`context`](#context) | `{String}` | `options.context \|\| compiler.options.context` | A path that determines how to interpret the `from` path. | | [`toType`](#totype) | `{String}` | `undefined` | Determinate what is `to` option - directory, file or template. | | [`test`](#test) | `{RegExp}` | `undefined` | Pattern for extracting elements to be used in `to` templates. | @@ -108,7 +108,7 @@ module.exports = { #### `to` Type: `String` -Default: `undefined` +Default: `compiler.options.output` Output path. diff --git a/src/index.js b/src/index.js index 466921b9..b48a68aa 100644 --- a/src/index.js +++ b/src/index.js @@ -95,6 +95,7 @@ class CopyPlugin { callback(); }); }); + compiler.hooks.afterEmit.tapAsync(plugin, (compilation, callback) => { logger.debug('starting after-emit'); diff --git a/test/to-option.test.js b/test/to-option.test.js index 6245c5ef..d42398af 100644 --- a/test/to-option.test.js +++ b/test/to-option.test.js @@ -448,5 +448,20 @@ describe('to option', () => { .then(done) .catch(done); }); + + it('should move a file to "compiler.options.output" by default', (done) => { + runEmit({ + compilation: { output: { path: '/path/to' } }, + expectedAssetKeys: ['newfile.txt'], + patterns: [ + { + from: 'file.txt', + to: 'newfile.txt', + }, + ], + }) + .then(done) + .catch(done); + }); }); });