copy-webpack-plugin
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -0,1 +1,8 @@ | ||
## 2.1.0 (April 16, 2016) | ||
* Added pattern-level context | ||
* Added pattern-level ignore | ||
* Added flattening | ||
## 2.0.0 (Apr 14, 2016) | ||
@@ -2,0 +9,0 @@ |
@@ -95,7 +95,7 @@ 'use strict'; | ||
var apply = function apply(compiler) { | ||
var baseDir = compiler.options.context; | ||
var webpackContext = compiler.options.context; | ||
var outputPath = getOutputDir(compiler); | ||
var fileDependencies = []; | ||
var contextDependencies = []; | ||
var ignoreList = options.ignore; | ||
var webpackIgnore = options.ignore || []; | ||
var copyUnmodified = options.copyUnmodified; | ||
@@ -113,5 +113,13 @@ var writtenAssets = void 0; | ||
var globOpts = void 0; | ||
var context = void 0; | ||
var ignoreList = webpackIgnore.concat(pattern.ignore || []); | ||
if (pattern.context && !_path2.default.isAbsolute(pattern.context)) { | ||
pattern.context = _path2.default.resolve(webpackContext, pattern.context); | ||
} | ||
context = pattern.context || webpackContext; | ||
globOpts = { | ||
cwd: baseDir | ||
cwd: context | ||
}; | ||
@@ -126,3 +134,3 @@ | ||
var relSrc = pattern.from; | ||
var absSrc = _path2.default.resolve(baseDir, relSrc); | ||
var absSrc = _path2.default.resolve(context, relSrc); | ||
@@ -148,2 +156,3 @@ relDest = pattern.to || ''; | ||
copyUnmodified: copyUnmodified, | ||
flatten: pattern.flatten, | ||
forceWrite: forceWrite, | ||
@@ -166,6 +175,11 @@ ignoreList: ignoreList, | ||
var absFileSrc = _path2.default.resolve(baseDir, relFileSrc); | ||
var absFileSrc = _path2.default.resolve(context, relFileSrc); | ||
relFileDest = pattern.to || ''; | ||
// Remove any directory references if flattening | ||
if (pattern.flatten) { | ||
relFileSrc = _path2.default.basename(relFileSrc); | ||
} | ||
var relFileDirname = _path2.default.dirname(relFileSrc); | ||
@@ -180,3 +194,3 @@ | ||
// Make the destination relative | ||
relFileDest = _path2.default.join(_path2.default.relative(baseDir, relFileDirname), _path2.default.basename(relFileSrc)); | ||
relFileDest = _path2.default.join(_path2.default.relative(context, relFileDirname), _path2.default.basename(relFileSrc)); | ||
@@ -183,0 +197,0 @@ // If the source is relative |
@@ -37,2 +37,3 @@ 'use strict'; | ||
var relDirDest = opts.relDirDest; | ||
var flatten = opts.flatten; | ||
var forceWrite = opts.forceWrite; | ||
@@ -50,2 +51,7 @@ var ignoreList = opts.ignoreList; | ||
// Remove any directory reference if flattening | ||
if (flatten) { | ||
relFileDest = _path2.default.join(relDirDest, _path2.default.basename(relFileDest)); | ||
} | ||
// Skip if it matches any of our ignore list | ||
@@ -52,0 +58,0 @@ if ((0, _shouldIgnore2.default)(relFileSrc, ignoreList)) { |
{ | ||
"name": "copy-webpack-plugin", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Copy files and directories in webpack", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -39,2 +39,13 @@ ## Copy Webpack Plugin | ||
- forces the plugin to overwrite files staged by previous plugins | ||
* `context` | ||
- is optional | ||
- defaults to the base context | ||
- is a pattern specific context | ||
* `flatten` | ||
- is optional | ||
- defaults to `false` | ||
- removes all directory references and only copies file names | ||
- if files have the same name, the result is non-deterministic | ||
* `ignore` | ||
- additional globs to ignore for this pattern | ||
@@ -46,2 +57,6 @@ #### Available options: | ||
- globs are evaluated on the `from` path, relative to the context | ||
* `copyUnmodified` | ||
- is optional | ||
- defaults to `false` (only copies modified files) | ||
- `true` copies all files while using watch or webpack-dev-server | ||
@@ -89,2 +104,9 @@ ### Examples | ||
}, | ||
// Copy glob results, relative to context | ||
{ | ||
context: 'from/directory', | ||
from: '**/*', | ||
to: '/absolute/path' | ||
}, | ||
@@ -116,3 +138,3 @@ // {output}/file/without/extension | ||
// to `true` copies all files. | ||
copyUnmodified: true // defaults to false | ||
copyUnmodified: true | ||
}) | ||
@@ -119,0 +141,0 @@ ] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45262
353
149