Socket
Socket
Sign inDemoInstall

copy-webpack-plugin

Package Overview
Dependencies
Maintainers
4
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy-webpack-plugin - npm Package Compare versions

Comparing version 4.6.0 to 5.0.0

dist/cjs.js

29

CHANGELOG.md

@@ -5,2 +5,31 @@ # Change Log

<a name="5.0.0"></a>
# [5.0.0](https://github.com/webpack-contrib/copy-webpack-plugin/compare/v4.6.0...v5.0.0) (2019-02-20)
### Bug Fixes
* copy only modified files when you use patterns with difference `to` and same `context` ([#341](https://github.com/webpack-contrib/copy-webpack-plugin/issues/341)) ([e808aa2](https://github.com/webpack-contrib/copy-webpack-plugin/commit/e808aa2))
* handle `[contenthash]` as template ([#328](https://github.com/webpack-contrib/copy-webpack-plugin/issues/328)) ([61dfe52](https://github.com/webpack-contrib/copy-webpack-plugin/commit/61dfe52))
* handles when you add new files in watch mode and use `glob` ([#333](https://github.com/webpack-contrib/copy-webpack-plugin/issues/333)) ([49a28f0](https://github.com/webpack-contrib/copy-webpack-plugin/commit/49a28f0))
* normalize path segment separation, no problems when you mixed `/` and `\\` ([#339](https://github.com/webpack-contrib/copy-webpack-plugin/issues/339)) ([8f5e638](https://github.com/webpack-contrib/copy-webpack-plugin/commit/8f5e638))
* throw error if `from` is an empty string [#278](https://github.com/webpack-contrib/copy-webpack-plugin/issues/278) ([#285](https://github.com/webpack-contrib/copy-webpack-plugin/issues/285)) ([adf1046](https://github.com/webpack-contrib/copy-webpack-plugin/commit/adf1046))
### Features
* emit warning instead error if file doesn't exist ([#338](https://github.com/webpack-contrib/copy-webpack-plugin/issues/338)) ([a1c5372](https://github.com/webpack-contrib/copy-webpack-plugin/commit/a1c5372))
* supports copy nested directories/files in symlink ([#335](https://github.com/webpack-contrib/copy-webpack-plugin/issues/335)) ([f551c0d](https://github.com/webpack-contrib/copy-webpack-plugin/commit/f551c0d))
### BREAKING CHANGES
* drop support for webpack < 4
* drop support for node < 6.9
* `debug` option was renamed to `logLevel`, it only accepts string values: `trace`, `debug`, `info`, `warn`, `error` and `silent`
* plugin emit warning instead error if file doesn't exist
* change `prototype` of plugin, now you can to get correct plugin name
<a name="4.6.0"></a>

@@ -7,0 +36,0 @@ # [4.6.0](https://github.com/webpack-contrib/copy-webpack-plugin/compare/v4.5.4...v4.6.0) (2018-10-31)

305

dist/index.js

@@ -1,240 +0,123 @@

'use strict';
"use strict";
var _path = require('path');
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _path2 = _interopRequireDefault(_path);
var _path = _interopRequireDefault(require("path"));
var _preProcessPattern = require('./preProcessPattern');
var _webpackLog = _interopRequireDefault(require("webpack-log"));
var _preProcessPattern2 = _interopRequireDefault(_preProcessPattern);
var _preProcessPattern = _interopRequireDefault(require("./preProcessPattern"));
var _processPattern = require('./processPattern');
var _processPattern = _interopRequireDefault(require("./processPattern"));
var _processPattern2 = _interopRequireDefault(_processPattern);
var _postProcessPattern = _interopRequireDefault(require("./postProcessPattern"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function CopyWebpackPlugin() {
var patterns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
class CopyPlugin {
constructor(patterns = [], options = {}) {
if (!Array.isArray(patterns)) {
throw new Error('[copy-webpack-plugin] patterns must be an array');
throw new Error('[copy-webpack-plugin] patterns must be an array');
}
// Defaults debug level to 'warning'
options.debug = options.debug || 'warning';
this.patterns = patterns;
this.options = options;
}
// Defaults debugging to info if only true is specified
if (options.debug === true) {
options.debug = 'info';
}
apply(compiler) {
const fileDependencies = new Set();
const contextDependencies = new Set();
const written = {};
let context;
var debugLevels = ['warning', 'info', 'debug'];
var debugLevelIndex = debugLevels.indexOf(options.debug);
function log(msg, level) {
if (level === 0) {
msg = 'WARNING - ' + msg;
} else {
level = level || 1;
}
if (level <= debugLevelIndex) {
console.log('[copy-webpack-plugin] ' + msg); // eslint-disable-line no-console
}
if (!this.options.context) {
({
context
} = compiler.options);
} else if (!_path.default.isAbsolute(this.options.context)) {
context = _path.default.join(compiler.options.context, this.options.context);
} else {
({
context
} = this.options);
}
function warning(msg) {
log(msg, 0);
}
const logger = (0, _webpackLog.default)({
name: 'copy-webpack-plugin',
level: this.options.logLevel || 'warn'
});
const plugin = {
name: 'CopyPlugin'
};
compiler.hooks.emit.tapAsync(plugin, (compilation, callback) => {
logger.debug('starting emit');
const globalRef = {
logger,
compilation,
written,
fileDependencies,
contextDependencies,
context,
inputFileSystem: compiler.inputFileSystem,
output: compiler.options.output.path,
ignore: this.options.ignore || [],
copyUnmodified: this.options.copyUnmodified,
concurrency: this.options.concurrency
};
function info(msg) {
log(msg, 1);
}
if (globalRef.output === '/' && compiler.options.devServer && compiler.options.devServer.outputPath) {
globalRef.output = compiler.options.devServer.outputPath;
}
function debug(msg) {
log(msg, 2);
}
const {
patterns
} = this;
Promise.all(patterns.map(pattern => Promise.resolve().then(() => (0, _preProcessPattern.default)(globalRef, pattern)) // Every source (from) is assumed to exist here
// eslint-disable-next-line no-shadow
.then(pattern => (0, _processPattern.default)(globalRef, pattern).then(files => {
if (!files) {
return Promise.resolve();
}
var apply = function apply(compiler) {
var fileDependencies = void 0;
var contextDependencies = void 0;
var written = {};
return Promise.all(files.filter(Boolean).map(file => (0, _postProcessPattern.default)(globalRef, pattern, file)));
})))).catch(error => {
compilation.errors.push(error);
}).then(() => {
logger.debug('finishing emit');
callback();
});
});
compiler.hooks.afterEmit.tapAsync(plugin, (compilation, callback) => {
logger.debug('starting after-emit'); // Add file dependencies if they're not already tracked
var context = void 0;
if (!options.context) {
context = compiler.options.context;
} else if (!_path2.default.isAbsolute(options.context)) {
context = _path2.default.join(compiler.options.context, options.context);
for (const fileDependency of fileDependencies) {
if (compilation.fileDependencies.has(fileDependency)) {
logger.debug(`not adding '${fileDependency}' to change tracking, because it's already tracked`);
} else {
context = options.context;
logger.debug(`adding '${fileDependency}' to change tracking`);
compilation.fileDependencies.add(fileDependency);
}
} // Add context dependencies if they're not already tracked
var emit = function emit(compilation, cb) {
debug('starting emit');
var callback = function callback() {
debug('finishing emit');
cb();
};
fileDependencies = [];
contextDependencies = [];
var globalRef = {
info: info,
debug: debug,
warning: warning,
compilation: compilation,
written: written,
fileDependencies: fileDependencies,
contextDependencies: contextDependencies,
context: context,
inputFileSystem: compiler.inputFileSystem,
output: compiler.options.output.path,
ignore: options.ignore || [],
copyUnmodified: options.copyUnmodified,
concurrency: options.concurrency
};
if (globalRef.output === '/' && compiler.options.devServer && compiler.options.devServer.outputPath) {
globalRef.output = compiler.options.devServer.outputPath;
}
var tasks = [];
patterns.forEach(function (pattern) {
tasks.push(Promise.resolve().then(function () {
return (0, _preProcessPattern2.default)(globalRef, pattern);
})
// Every source (from) is assumed to exist here
.then(function (pattern) {
return (0, _processPattern2.default)(globalRef, pattern);
}));
});
Promise.all(tasks).catch(function (err) {
compilation.errors.push(err);
}).then(function () {
return callback();
});
};
var afterEmit = function afterEmit(compilation, cb) {
debug('starting after-emit');
var callback = function callback() {
debug('finishing after-emit');
cb();
};
var compilationFileDependencies = void 0;
var addFileDependency = void 0;
if (Array.isArray(compilation.fileDependencies)) {
compilationFileDependencies = new Set(compilation.fileDependencies);
addFileDependency = function addFileDependency(file) {
return compilation.fileDependencies.push(file);
};
} else {
compilationFileDependencies = compilation.fileDependencies;
addFileDependency = function addFileDependency(file) {
return compilation.fileDependencies.add(file);
};
}
var compilationContextDependencies = void 0;
var addContextDependency = void 0;
if (Array.isArray(compilation.contextDependencies)) {
compilationContextDependencies = new Set(compilation.contextDependencies);
addContextDependency = function addContextDependency(file) {
return compilation.contextDependencies.push(file);
};
} else {
compilationContextDependencies = compilation.contextDependencies;
addContextDependency = function addContextDependency(file) {
return compilation.contextDependencies.add(file);
};
}
// Add file dependencies if they're not already tracked
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = fileDependencies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var file = _step.value;
if (compilationFileDependencies.has(file)) {
debug('not adding ' + file + ' to change tracking, because it\'s already tracked');
} else {
debug('adding ' + file + ' to change tracking');
addFileDependency(file);
}
}
// Add context dependencies if they're not already tracked
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = contextDependencies[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _context = _step2.value;
if (compilationContextDependencies.has(_context)) {
debug('not adding ' + _context + ' to change tracking, because it\'s already tracked');
} else {
debug('adding ' + _context + ' to change tracking');
addContextDependency(_context);
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
callback();
};
if (compiler.hooks) {
var plugin = { name: 'CopyPlugin' };
compiler.hooks.emit.tapAsync(plugin, emit);
compiler.hooks.afterEmit.tapAsync(plugin, afterEmit);
for (const contextDependency of contextDependencies) {
if (compilation.contextDependencies.has(contextDependency)) {
logger.debug(`not adding '${contextDependency}' to change tracking, because it's already tracked`);
} else {
compiler.plugin('emit', emit);
compiler.plugin('after-emit', afterEmit);
logger.debug(`adding '${contextDependency}' to change tracking`);
compilation.contextDependencies.add(contextDependency);
}
};
}
return {
apply: apply
};
logger.debug('finishing after-emit');
callback();
});
}
}
CopyWebpackPlugin['default'] = CopyWebpackPlugin;
module.exports = CopyWebpackPlugin;
var _default = CopyPlugin;
exports.default = _default;

@@ -1,139 +0,150 @@

'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = preProcessPattern;
var _path = require('path');
var _path = _interopRequireDefault(require("path"));
var _path2 = _interopRequireDefault(_path);
var _isGlob = _interopRequireDefault(require("is-glob"));
var _isGlob = require('is-glob');
var _normalizePath = _interopRequireDefault(require("normalize-path"));
var _isGlob2 = _interopRequireDefault(_isGlob);
var _normalize = _interopRequireDefault(require("./utils/normalize"));
var _escape = require('./utils/escape');
var _isObject = _interopRequireDefault(require("./utils/isObject"));
var _escape2 = _interopRequireDefault(_escape);
var _promisify = require("./utils/promisify");
var _isObject = require('./utils/isObject');
var _isObject2 = _interopRequireDefault(_isObject);
var _promisify = require('./utils/promisify');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// https://www.debuggex.com/r/VH2yS2mvJOitiyr3
var 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 */
function preProcessPattern(globalRef, pattern) {
var info = globalRef.info,
debug = globalRef.debug,
warning = globalRef.warning,
context = globalRef.context,
inputFileSystem = globalRef.inputFileSystem,
fileDependencies = globalRef.fileDependencies,
contextDependencies = globalRef.contextDependencies,
compilation = globalRef.compilation;
const {
logger,
context,
inputFileSystem,
fileDependencies,
contextDependencies,
compilation
} = globalRef;
pattern = typeof pattern === 'string' ? {
from: pattern
} : Object.assign({}, pattern);
if (pattern.from === '') {
const message = 'path "from" cannot be empty string';
logger.error(message);
throw new Error(message);
}
pattern = typeof pattern === 'string' ? {
from: pattern
} : Object.assign({}, pattern);
pattern.to = pattern.to || '';
pattern.context = pattern.context || context;
if (!_path2.default.isAbsolute(pattern.context)) {
pattern.context = _path2.default.join(context, pattern.context);
}
pattern.ignore = globalRef.ignore.concat(pattern.ignore || []);
pattern.to = pattern.to || '';
pattern.context = pattern.context || context;
info('processing from: \'' + pattern.from + '\' to: \'' + pattern.to + '\'');
if (!_path.default.isAbsolute(pattern.context)) {
pattern.context = _path.default.join(context, pattern.context);
}
switch (true) {
case !!pattern.toType:
// if toType already exists
break;
case isTemplateLike.test(pattern.to):
pattern.toType = 'template';
break;
case _path2.default.extname(pattern.to) === '' || pattern.to.slice(-1) === '/':
pattern.toType = 'dir';
break;
default:
pattern.toType = 'file';
}
pattern.context = (0, _normalizePath.default)(pattern.context);
pattern.ignore = globalRef.ignore.concat(pattern.ignore || []);
logger.debug(`processing from: '${pattern.from}' to: '${pattern.to}'`);
debug('determined \'' + pattern.to + '\' is a \'' + pattern.toType + '\'');
switch (true) {
// if toType already exists
case !!pattern.toType:
break;
// If we know it's a glob, then bail early
if ((0, _isObject2.default)(pattern.from) && pattern.from.glob) {
pattern.fromType = 'glob';
case isTemplateLike.test(pattern.to):
pattern.toType = 'template';
break;
var fromArgs = Object.assign({}, pattern.from);
delete fromArgs.glob;
case _path.default.extname(pattern.to) === '' || pattern.to.slice(-1) === '/':
pattern.toType = 'dir';
break;
pattern.fromArgs = fromArgs;
pattern.glob = (0, _escape2.default)(pattern.context, pattern.from.glob);
pattern.absoluteFrom = _path2.default.resolve(pattern.context, pattern.from.glob);
return Promise.resolve(pattern);
}
default:
pattern.toType = 'file';
} // If we know it's a glob, then bail early
if (_path2.default.isAbsolute(pattern.from)) {
pattern.absoluteFrom = pattern.from;
if ((0, _isObject.default)(pattern.from) && pattern.from.glob) {
logger.debug(`determined '${pattern.absoluteFrom}' is a glob`);
pattern.fromType = 'glob';
const globOptions = Object.assign({}, pattern.from);
delete globOptions.glob;
pattern.glob = (0, _normalize.default)(pattern.context, pattern.from.glob);
pattern.globOptions = globOptions;
pattern.absoluteFrom = (0, _normalizePath.default)(_path.default.resolve(pattern.context, pattern.from.glob));
return Promise.resolve(pattern);
}
if (_path.default.isAbsolute(pattern.from)) {
pattern.absoluteFrom = pattern.from;
} else {
pattern.absoluteFrom = _path.default.resolve(pattern.context, pattern.from);
} // Normalize path when path separators are mixed (like `C:\\directory/nested-directory/`)
pattern.absoluteFrom = (0, _normalizePath.default)(pattern.absoluteFrom);
logger.debug(`determined '${pattern.from}' to be read from '${pattern.absoluteFrom}'`);
const noStatsHandler = () => {
// If from doesn't appear to be a glob, then log a warning
if ((0, _isGlob.default)(pattern.from) || pattern.from.indexOf('*') !== -1) {
logger.debug(`determined '${pattern.absoluteFrom}' is a glob`);
pattern.fromType = 'glob';
pattern.glob = (0, _normalize.default)(pattern.context, pattern.from); // We need to add context directory as dependencies to avoid problems when new files added in directories
// when we already in watch mode and this directories are not in context dependencies
contextDependencies.add(pattern.context);
} else {
pattern.absoluteFrom = _path2.default.resolve(pattern.context, pattern.from);
}
const newWarning = new Error(`unable to locate '${pattern.from}' at '${pattern.absoluteFrom}'`);
const hasWarning = compilation.warnings.some( // eslint-disable-next-line no-shadow
warning => warning.message === newWarning.message); // Only display the same message once
debug('determined \'' + pattern.from + '\' to be read from \'' + pattern.absoluteFrom + '\'');
if (!hasWarning) {
logger.warn(newWarning.message);
compilation.warnings.push(newWarning);
}
var noStatsHandler = function noStatsHandler() {
// If from doesn't appear to be a glob, then log a warning
if ((0, _isGlob2.default)(pattern.from) || pattern.from.indexOf('*') !== -1) {
pattern.fromType = 'glob';
pattern.glob = (0, _escape2.default)(pattern.context, pattern.from);
} else {
var msg = 'unable to locate \'' + pattern.from + '\' at \'' + pattern.absoluteFrom + '\'';
var warningMsg = '[copy-webpack-plugin] ' + msg;
// only display the same message once
if (compilation.errors.indexOf(warningMsg) === -1) {
warning(msg);
compilation.errors.push(warningMsg);
}
pattern.fromType = 'nonexistent';
}
};
pattern.fromType = 'nonexistent';
}
};
logger.debug(`getting stats for '${pattern.absoluteFrom}' to determinate 'fromType'`);
return (0, _promisify.stat)(inputFileSystem, pattern.absoluteFrom).catch(() => noStatsHandler()).then(stats => {
if (!stats) {
noStatsHandler();
return pattern;
}
return (0, _promisify.stat)(inputFileSystem, pattern.absoluteFrom).catch(function () {
return noStatsHandler();
}).then(function (stat) {
if (!stat) {
noStatsHandler();
return pattern;
}
if (stats.isDirectory()) {
logger.debug(`determined '${pattern.absoluteFrom}' is a directory`);
contextDependencies.add(pattern.absoluteFrom);
pattern.fromType = 'dir';
pattern.context = pattern.absoluteFrom;
pattern.glob = (0, _normalize.default)(pattern.absoluteFrom, '**/*');
pattern.absoluteFrom = (0, _normalizePath.default)(_path.default.join(pattern.absoluteFrom, '**/*'));
pattern.globOptions = {
dot: true
};
} else if (stats.isFile()) {
logger.debug(`determined '${pattern.absoluteFrom}' is a file`);
fileDependencies.add(pattern.absoluteFrom);
pattern.fromType = 'file';
pattern.context = (0, _normalizePath.default)(_path.default.dirname(pattern.absoluteFrom));
pattern.glob = (0, _normalize.default)(pattern.absoluteFrom);
pattern.globOptions = {
dot: true
};
} else if (!pattern.fromType) {
logger.warn(`unrecognized file type for ${pattern.from}`);
}
if (stat.isDirectory()) {
pattern.fromType = 'dir';
pattern.context = pattern.absoluteFrom;
contextDependencies.push(pattern.absoluteFrom);
pattern.glob = (0, _escape2.default)(pattern.absoluteFrom, '**/*');
pattern.absoluteFrom = _path2.default.join(pattern.absoluteFrom, '**/*');
pattern.fromArgs = {
dot: true
};
} else if (stat.isFile()) {
pattern.fromType = 'file';
pattern.context = _path2.default.dirname(pattern.absoluteFrom);
pattern.glob = (0, _escape2.default)(pattern.absoluteFrom);
pattern.fromArgs = {
dot: true
};
fileDependencies.push(pattern.absoluteFrom);
} else if (!pattern.fromType) {
info('Unrecognized file type for ' + pattern.from);
}
return pattern;
});
return pattern;
});
}

@@ -1,138 +0,111 @@

'use strict';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = processPattern;
var _globby = require('globby');
var _path = _interopRequireDefault(require("path"));
var _globby2 = _interopRequireDefault(_globby);
var _globby = _interopRequireDefault(require("globby"));
var _pLimit = require('p-limit');
var _pLimit = _interopRequireDefault(require("p-limit"));
var _pLimit2 = _interopRequireDefault(_pLimit);
var _minimatch = _interopRequireDefault(require("minimatch"));
var _isGlob = require('is-glob');
var _normalizePath = _interopRequireDefault(require("normalize-path"));
var _isGlob2 = _interopRequireDefault(_isGlob);
var _isObject = _interopRequireDefault(require("./utils/isObject"));
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _minimatch = require('minimatch');
var _minimatch2 = _interopRequireDefault(_minimatch);
var _writeFile = require('./writeFile');
var _writeFile2 = _interopRequireDefault(_writeFile);
var _isObject = require('./utils/isObject');
var _isObject2 = _interopRequireDefault(_isObject);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function processPattern(globalRef, pattern) {
var info = globalRef.info,
debug = globalRef.debug,
output = globalRef.output,
concurrency = globalRef.concurrency,
contextDependencies = globalRef.contextDependencies;
const {
logger,
output,
concurrency
} = globalRef;
const globOptions = Object.assign({
cwd: pattern.context,
follow: true
}, pattern.globOptions || {});
var globArgs = Object.assign({
cwd: pattern.context
}, pattern.fromArgs || {});
if (pattern.fromType === 'nonexistent') {
return Promise.resolve();
}
if (pattern.fromType === 'nonexistent') {
return Promise.resolve();
}
const limit = (0, _pLimit.default)(concurrency || 100);
logger.info(`begin globbing '${pattern.glob}' with a context of '${pattern.context}'`);
return (0, _globby.default)(pattern.glob, globOptions).then(paths => Promise.all(paths.map(from => limit(() => {
const file = {
force: pattern.force,
absoluteFrom: _path.default.resolve(pattern.context, from)
};
file.relativeFrom = _path.default.relative(pattern.context, file.absoluteFrom);
var limit = (0, _pLimit2.default)(concurrency || 100);
if (pattern.flatten) {
file.relativeFrom = _path.default.basename(file.relativeFrom);
} // Ensure forward slashes
info('begin globbing \'' + pattern.glob + '\' with a context of \'' + pattern.context + '\'');
return (0, _globby2.default)(pattern.glob, globArgs).then(function (paths) {
return Promise.all(paths.map(function (from) {
return limit(function () {
var file = {
force: pattern.force,
absoluteFrom: _path2.default.resolve(pattern.context, from)
};
file.relativeFrom = _path2.default.relative(pattern.context, file.absoluteFrom);
if (pattern.flatten) {
file.relativeFrom = _path2.default.basename(file.relativeFrom);
}
file.relativeFrom = (0, _normalizePath.default)(file.relativeFrom);
logger.debug(`found ${from}`); // Check the ignore list
// This is so webpack is able to watch the directory and when
// a new file is added it triggeres a rebuild
var contextPath = _path2.default.dirname(_path2.default.resolve(from));
if (contextDependencies.indexOf(contextPath) === -1 && (0, _isGlob2.default)(pattern.glob)) {
contextDependencies.push(contextPath);
}
let il = pattern.ignore.length; // eslint-disable-next-line no-plusplus
debug('found ' + from);
while (il--) {
const ignoreGlob = pattern.ignore[il];
let globParams = {
dot: true,
matchBase: true
};
let glob;
// Check the ignore list
var il = pattern.ignore.length;
while (il--) {
var ignoreGlob = pattern.ignore[il];
if (typeof ignoreGlob === 'string') {
glob = ignoreGlob;
} else if ((0, _isObject.default)(ignoreGlob)) {
glob = ignoreGlob.glob || '';
const ignoreGlobParams = Object.assign({}, ignoreGlob);
delete ignoreGlobParams.glob; // Overwrite minimatch defaults
var globParams = {
dot: true,
matchBase: true
};
globParams = Object.assign(globParams, ignoreGlobParams);
} else {
glob = '';
}
var glob = void 0;
if (typeof ignoreGlob === 'string') {
glob = ignoreGlob;
} else if ((0, _isObject2.default)(ignoreGlob)) {
glob = ignoreGlob.glob || '';
var ignoreGlobParams = Object.assign({}, ignoreGlob);
delete ignoreGlobParams.glob;
logger.debug(`testing ${glob} against ${file.relativeFrom}`);
// Overwrite minimatch defaults
globParams = Object.assign(globParams, ignoreGlobParams);
} else {
glob = '';
}
if ((0, _minimatch.default)(file.relativeFrom, glob, globParams)) {
logger.info(`ignoring '${file.relativeFrom}', because it matches the ignore glob '${glob}'`);
return Promise.resolve();
}
debug('testing ' + glob + ' against ' + file.relativeFrom);
if ((0, _minimatch2.default)(file.relativeFrom, glob, globParams)) {
info('ignoring \'' + file.relativeFrom + '\', because it matches the ignore glob \'' + glob + '\'');
return Promise.resolve();
} else {
debug(glob + ' doesn\'t match ' + file.relativeFrom);
}
}
logger.debug(`${glob} doesn't match ${file.relativeFrom}`);
} // Change the to path to be relative for webpack
// Change the to path to be relative for webpack
if (pattern.toType === 'dir') {
file.webpackTo = _path2.default.join(pattern.to, file.relativeFrom);
} else if (pattern.toType === 'file') {
file.webpackTo = pattern.to || file.relativeFrom;
} else if (pattern.toType === 'template') {
file.webpackTo = pattern.to;
file.webpackToRegExp = pattern.test;
}
if (_path2.default.isAbsolute(file.webpackTo)) {
if (output === '/') {
throw '[copy-webpack-plugin] Using older versions of webpack-dev-server, devServer.outputPath must be defined to write to absolute paths';
}
if (pattern.toType === 'dir') {
file.webpackTo = _path.default.join(pattern.to, file.relativeFrom);
} else if (pattern.toType === 'file') {
file.webpackTo = pattern.to || file.relativeFrom;
} else if (pattern.toType === 'template') {
file.webpackTo = pattern.to;
file.webpackToRegExp = pattern.test;
}
file.webpackTo = _path2.default.relative(output, file.webpackTo);
}
if (_path.default.isAbsolute(file.webpackTo)) {
if (output === '/') {
const message = 'using older versions of webpack-dev-server, devServer.outputPath must be defined to write to absolute paths';
logger.error(message);
throw new Error(message);
}
// ensure forward slashes
file.webpackTo = file.webpackTo.replace(/\\/g, '/');
file.webpackTo = _path.default.relative(output, file.webpackTo);
} // Ensure forward slashes
info('determined that \'' + from + '\' should write to \'' + file.webpackTo + '\'');
return (0, _writeFile2.default)(globalRef, pattern, file);
});
}));
});
file.webpackTo = (0, _normalizePath.default)(file.webpackTo);
logger.info(`determined that '${from}' should write to '${file.webpackTo}'`);
return file;
}))));
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,5 +6,6 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
exports.default = function (val) {
return Object.prototype.toString.call(val) === '[object Object]' ? true : false;
};
var _default = val => Object.prototype.toString.call(val) === '[object Object]';
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
var stat = exports.stat = function stat(inputFileSystem, path) {
return new Promise(function (resolve, reject) {
inputFileSystem.stat(path, function (err, stats) {
if (err) {
reject(err);
}
resolve(stats);
});
});
};
exports.readFile = exports.stat = void 0;
var readFile = exports.readFile = function readFile(inputFileSystem, path) {
return new Promise(function (resolve, reject) {
inputFileSystem.readFile(path, function (err, stats) {
if (err) {
reject(err);
}
resolve(stats);
});
});
};
const stat = (inputFileSystem, path) => new Promise((resolve, reject) => {
inputFileSystem.stat(path, (err, stats) => {
if (err) {
reject(err);
}
resolve(stats);
});
});
exports.stat = stat;
const readFile = (inputFileSystem, path) => new Promise((resolve, reject) => {
inputFileSystem.readFile(path, (err, stats) => {
if (err) {
reject(err);
}
resolve(stats);
});
});
exports.readFile = readFile;
{
"name": "copy-webpack-plugin",
"version": "4.6.0",
"version": "5.0.0",
"description": "Copy files && directories with webpack",
"license": "MIT",
"repository": "webpack-contrib/copy-webpack-plugin",
"author": "Len Boyette",
"license": "MIT",
"main": "dist/index.js",
"homepage": "https://github.com/webpack-contrib/copy-webpack-plugin",
"bugs": "https://github.com/webpack-contrib/copy-webpack-plugin/issues",
"main": "dist/cjs.js",
"engines": {
"node": ">= 4"
"node": ">= 6.9.0"
},
"scripts": {
"start": "npm run build -- -w",
"prebuild": "npm run clean",
"build": "cross-env NODE_ENV=production babel src -d dist --ignore 'src/**/*.test.js' --copy-files",
"clean": "del-cli dist",
"commitlint": "commitlint",
"commitmsg": "commitlint -e $GIT_PARAMS",
"lint": "eslint --cache src test",
"prepublish": "npm run build",
"release": "standard-version",
"security": "npm audit",
"test:only": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage",
"pretest": "npm run lint",
"test": "npm run test:only",
"ci:lint": "npm run lint && npm run security",
"ci:test": "npm run test:only -- --runInBand",
"ci:coverage": "npm run test:coverage -- --runInBand",
"ci:lint:commits": "commitlint --from=origin/master --to=${CIRCLE_SHA1}",
"defaults": "webpack-defaults"
},
"files": [
"dist"
],
"scripts": {
"lint": "eslint src/ tests/",
"prepare": "npm run build",
"release": "standard-version",
"pretest": "npm run lint && npm run build && npm run build:tests",
"test": "mocha compiled_tests/",
"build": "babel src/ --out-dir dist/",
"build:tests": "babel tests/ --out-dir compiled_tests/ && rimraf compiled_tests/helpers && ncp tests/helpers compiled_tests/helpers && node scripts/createSpecialDirectory.js"
"peerDependencies": {
"webpack": "^4.0.0"
},
"dependencies": {
"cacache": "^11.3.1",
"find-cache-dir": "^2.0.0",
"globby": "^7.1.1",
"cacache": "^10.0.4",
"find-cache-dir": "^1.0.0",
"serialize-javascript": "^1.4.0",
"is-glob": "^4.0.0",
"loader-utils": "^1.1.0",
"minimatch": "^3.0.4",
"p-limit": "^1.0.0"
"normalize-path": "^3.0.0",
"p-limit": "^2.1.0",
"serialize-javascript": "^1.4.0",
"webpack-log": "^2.0.0"
},
"devDependencies": {
"babel-cli": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"chai": "^3.4.0",
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.6",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.6",
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"@webpack-contrib/defaults": "^3.0.5",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^24.1.0",
"cross-env": "^5.1.3",
"del": "^3.0.0",
"del-cli": "^1.1.0",
"enhanced-resolve": "^3.4.1",
"eslint": "^2.9.0",
"eslint": "^5.13.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-prettier": "^3.0.0",
"husky": "^1.2.1",
"is-gzip": "^2.0.0",
"jest": "^24.0.0",
"lint-staged": "^8.1.0",
"memory-fs": "^0.4.1",
"mkdirp": "^0.5.1",
"mocha": "^2.4.5",
"ncp": "^2.0.0",
"rimraf": "^2.6.2",
"standard-version": "^4.2.0"
"prettier": "^1.14.0",
"spdy": "^4.0.0",
"standard-version": "^5.0.0",
"webpack": "^4.29.4"
},
"homepage": "https://github.com/webpack-contrib/copy-webpack-plugin",
"bugs": "https://github.com/webpack-contrib/copy-webpack-plugin/issues",
"repository": "https://github.com/webpack-contrib/copy-webpack-plugin.git",
"keywords": [

@@ -55,3 +88,37 @@ "webpack",

"copy"
]
],
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "6.9.0"
},
"useBuiltIns": "usage"
}
]
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
]
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"prettier": {
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "always"
}
}

@@ -1,8 +0,1 @@

[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![test][test]][test-url]
[![coverage][cover]][cover-url]
[![chat][chat]][chat-url]
<div align="center">

@@ -13,138 +6,168 @@ <a href="https://github.com/webpack/webpack">

</a>
<h1>Copy Webpack Plugin</h1>
<p>Copies individual files or entire directories to the build directory</p>
</div>
<h2 align="center">Install</h2>
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![cover][cover]][cover-url]
[![chat][chat]][chat-url]
[![size][size]][size-url]
```bash
npm i -D copy-webpack-plugin
# copy-webpack-plugin
Copies individual files or entire directories to the build directory.
## Getting Started
To begin, you'll need to install `copy-webpack-plugin`:
```console
$ npm install copy-webpack-plugin --save-dev
```
<h2 align="center">Usage</h2>
Then add the loader to your `webpack` config. For example:
**webpack.config.js**
```js
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin');
const config = {
module.exports = {
plugins: [
new CopyWebpackPlugin([ ...patterns ], options)
]
}
new CopyPlugin([
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
]),
],
};
```
> ℹ️ If you want `webpack-dev-server` to write files to the output directory during development, you can force it with the [`write-file-webpack-plugin`](https://github.com/gajus/write-file-webpack-plugin).
> ℹ️ If you want `webpack-dev-server` to write files to the output directory during development, you can force it with the [`writeToDisk`](https://github.com/webpack/webpack-dev-middleware#writetodisk) option or the [`write-file-webpack-plugin`](https://github.com/gajus/write-file-webpack-plugin).
### `Patterns`
## Options
A simple pattern looks like this
The plugin's signature:
**webpack.config.js**
```js
{ from: 'source', to: 'dest' }
module.exports = {
plugins: [new CopyPlugin(patterns, options)],
};
```
Or, in case of just a `from` with the default destination, you can also use a `{String}` as shorthand instead of an `{Object}`
### Patterns
```js
'source'
```
| Name | Type | Default | Description |
| :-------------------------------: | :-------------------: | :---------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`from`](#from) | `{String\|Object}` | `undefined` | Globs accept [minimatch options](https://github.com/isaacs/minimatch). See the [`node-glob` options](https://github.com/isaacs/node-glob#options) in addition to the ones below. |
| [`to`](#to) | `{String\|Object}` | `undefined` | Output root if `from` is file or dir, resolved glob path if `from` is glob. |
| [`toType`](#toType) | `{String}` | `undefined` | `[toType Options](#totype)`. |
| [`test`](#test) | `{RegExp}` | `undefined` | Pattern for extracting elements to be used in `to` templates. |
| [`force`](#force) | `{Boolean}` | `false` | Overwrites files already in `compilation.assets` (usually added by other plugins/loaders). |
| [`ignore`](#ignore) | `{Array}` | `[]` | Globs to ignore for this pattern. |
| [`flatten`](#flatten) | `{Boolean}` | `false` | Removes all directory references and only copies file names.⚠️ If files have the same name, the result is non-deterministic. |
| [`transform`](#transform) | `{Function\|Promise}` | `(content, path) => content` | Function or Promise that modifies file contents before copying. |
| [`transformPath`](#transformPath) | `{Function\|Promise}` | `(targetPath, sourcePath) => path` | Function or Promise that modifies file writing path. |
| [`cache`](#cache) | `{Boolean\|Object}` | `false` | Enable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache. |
| [`context`](#context) | `{String}` | `options.context \|\| compiler.options.context` | A path that determines how to interpret the `from` path. |
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|[`from`](#from)|`{String\|Object}`|`undefined`|Globs accept [minimatch options](https://github.com/isaacs/minimatch)|
|[`fromArgs`](#fromArgs)|`{Object}`|`{ cwd: context }`|See the [`node-glob` options](https://github.com/isaacs/node-glob#options) in addition to the ones below|
|[`to`](#to)|`{String\|Object}`|`undefined`|Output root if `from` is file or dir, resolved glob path if `from` is glob|
|[`toType`](#toType)|`{String}`|``|[toType Options](#totype)|
|[`test`](#test)|`{RegExp}`|``|Pattern for extracting elements to be used in `to` templates|
|[`force`](#force)|`{Boolean}`|`false`|Overwrites files already in `compilation.assets` (usually added by other plugins/loaders)|
|[`ignore`](#ignore)|`{Array}`|`[]`|Globs to ignore for this pattern|
|`flatten`|`{Boolean}`|`false`|Removes all directory references and only copies file names.⚠️ If files have the same name, the result is non-deterministic|
|[`transform`](#transform)|`{Function\|Promise}`|`(content, path) => content`|Function or Promise that modifies file contents before copying|
|[`transformPath`](#transformPath)|`{Function\|Promise}`|`(targetPath, sourcePath) => path`|Function or Promise that modifies file writing path|
|[`cache`](#cache)|`{Boolean\|Object}`|`false`|Enable `transform` caching. You can use `{ cache: { key: 'my-cache-key' } }` to invalidate the cache|
|[`context`](#context)|`{String}`|`options.context \|\| compiler.options.context`|A path that determines how to interpret the `from` path|
#### `from`
### `from`
**webpack.config.js**
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
'relative/path/to/file.ext',
'/absolute/path/to/file.ext',
'relative/path/to/dir',
'/absolute/path/to/dir',
'**/*',
{ glob: '\*\*/\*', dot: true }
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
'relative/path/to/file.ext',
'/absolute/path/to/file.ext',
'relative/path/to/dir',
'/absolute/path/to/dir',
'**/*',
{ glob: '**/*', dot: false },
]),
],
};
```
### `to`
#### `to`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{ from: '**/*', to: 'relative/path/to/dest/' },
{ from: '**/*', to: '/absolute/path/to/dest/' }
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{ from: '**/*', to: 'relative/path/to/dest/' },
{ from: '**/*', to: '/absolute/path/to/dest/' },
]),
],
};
```
### `toType`
#### `toType`
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`'dir'`**|`{String}`|`undefined`|If `from` is directory, `to` has no extension or ends in `'/'`|
|**`'file'`**|`{String}`|`undefined`|If `to` has extension or `from` is file|
|**`'template'`**|`{String}`|`undefined`|If `to` contains [a template pattern](https://github.com/webpack-contrib/file-loader#placeholders)|
| Name | Type | Default | Description |
| :--------------: | :--------: | :---------: | :------------------------------------------------------------------------------------------------- |
| **`'dir'`** | `{String}` | `undefined` | If `from` is directory, `to` has no extension or ends in `'/'` |
| **`'file'`** | `{String}` | `undefined` | If `to` has extension or `from` is file |
| **`'template'`** | `{String}` | `undefined` | If `to` contains [a template pattern](https://github.com/webpack-contrib/file-loader#placeholders) |
#### `'dir'`
##### `'dir'`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'path/to/file.txt',
to: 'directory/with/extension.ext',
toType: 'dir'
}
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'path/to/file.txt',
to: 'directory/with/extension.ext',
toType: 'dir',
},
]),
],
};
```
#### `'file'`
##### `'file'`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'path/to/file.txt',
to: 'file/without/extension',
toType: 'file'
},
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'path/to/file.txt',
to: 'file/without/extension',
toType: 'file',
},
]),
],
};
```
#### `'template'`
##### `'template'`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'src/',
to: 'dest/[name].[hash].[ext]',
toType: 'template'
}
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/',
to: 'dest/[name].[hash].[ext]',
toType: 'template',
},
]),
],
};
```
### `test`
#### `test`

@@ -158,227 +181,270 @@ Defines a `{RegExp}` to match some parts of the file path.

**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: '*/*',
to: '[1]-[2].[hash].[ext]',
test: /([^/]+)\/(.+)\.png$/
}
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: '*/*',
to: '[1]-[2].[hash].[ext]',
test: /([^/]+)\/(.+)\.png$/,
},
]),
],
};
```
### `force`
#### `force`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{ from: 'src/**/*', to: 'dest/', force: true }
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/**/*',
to: 'dest/',
force: true,
},
]),
],
};
```
### `ignore`
#### `ignore`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{ from: 'src/**/*', to: 'dest/', ignore: [ '*.js' ] }
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/**/*',
to: 'dest/',
ignore: ['*.js'],
},
]),
],
};
```
### `flatten`
#### `flatten`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{ from: 'src/**/*', to: 'dest/', flatten: true }
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/**/*',
to: 'dest/',
flatten: true,
},
]),
],
};
```
### `transform`
#### `transform`
#### `{Function}`
##### `{Function}`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'src/*.png',
to: 'dest/',
transform (content, path) {
return optimize(content)
}
}
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/*.png',
to: 'dest/',
transform(content, path) {
return optimize(content);
},
},
]),
],
};
```
#### `{Promise}`
##### `{Promise}`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'src/*.png',
to: 'dest/',
transform (content, path) {
return Promise.resolve(optimize(content))
}
}
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/*.png',
to: 'dest/',
transform(content, path) {
return Promise.resolve(optimize(content));
},
},
]),
],
};
```
### `transformPath`
#### `transformPath`
#### `{Function}`
##### `{Function}`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'src/*.png',
to: 'dest/',
transformPath (targetPath, absolutePath) {
return 'newPath';
}
}
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/*.png',
to: 'dest/',
transformPath(targetPath, absolutePath) {
return 'newPath';
},
},
]),
],
};
```
#### `{Promise}`
##### `{Promise}`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'src/*.png',
to: 'dest/',
transform (targePath, absolutePath) {
return Promise.resolve('newPath')
}
}
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/*.png',
to: 'dest/',
transformPath(targePath, absolutePath) {
return Promise.resolve('newPath');
},
},
]),
],
};
```
#### `cache`
### `cache`
**webpack.config.js**
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{
from: 'src/*.png',
to: 'dest/',
transform (content, path) {
return optimize(content)
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/*.png',
to: 'dest/',
transform(content, path) {
return optimize(content);
},
cache: true,
},
cache: true
}
], options)
]
]),
],
};
```
### `context`
#### `context`
**webpack.config.js**
```js
[
new CopyWebpackPlugin([
{ from: 'src/*.txt', to: 'dest/', context: 'app/' }
], options)
]
module.exports = {
plugins: [
new CopyPlugin([
{
from: 'src/*.txt',
to: 'dest/',
context: 'app/',
},
]),
],
};
```
<h2 align="center">Options</h2>
### Options
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|[`debug`](#debug)|`{String}`|**`'warning'`**|[Debug Options](#debug)|
|[`ignore`](#ignore)|`{Array}`|`[]`|Array of globs to ignore (applied to `from`)|
|[`context`](#context)|`{String}`|`compiler.options.context`|A path that determines how to interpret the `from` path, shared for all patterns|
|[`copyUnmodified`](#copyUnmodified)|`{Boolean}`|`false`|Copies files, regardless of modification when using watch or `webpack-dev-server`. All files are copied on first build, regardless of this option|
| Name | Type | Default | Description |
| :---------------------------------: | :---------: | :------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`logLevel`](#logLevel) | `{String}` | **`'warning'`** | Level of messages that the module will log |
| [`ignore`](#ignore) | `{Array}` | `[]` | Array of globs to ignore (applied to `from`) |
| [`context`](#context) | `{String}` | `compiler.options.context` | A path that determines how to interpret the `from` path, shared for all patterns |
| [`copyUnmodified`](#copyUnmodified) | `{Boolean}` | `false` | Copies files, regardless of modification when using watch or `webpack-dev-server`. All files are copied on first build, regardless of this option |
### `debug`
#### `logLevel`
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`'info'`**|`{String\|Boolean}`|`false`|File location and read info|
|**`'debug'`**|`{String}`|`false`|Very detailed debugging info|
|**`'warning'`**|`{String}`|`true`|Only warnings|
This property defines the level of messages that the module will log. Valid levels include:
#### `'info'`
- `trace`
- `debug`
- `info`
- `warn`
- `error`
- `silent`
Setting a log level means that all other levels below it will be visible in the
console. Setting `logLevel: 'silent'` will hide all console output. The module
leverages [`webpack-log`](https://github.com/webpack-contrib/webpack-log#readme)
for logging management, and more information can be found on its page.
##### `'info'`
**webpack.config.js**
```js
[
new CopyWebpackPlugin(
[ ...patterns ],
{ debug: 'info' }
)
]
module.exports = {
plugins: [new CopyPlugin([...patterns], { debug: 'info' })],
};
```
#### `'debug'`
##### `'debug'`
**webpack.config.js**
```js
[
new CopyWebpackPlugin(
[ ...patterns ],
{ debug: 'debug' }
)
]
module.exports = {
plugins: [new CopyPlugin([...patterns], { debug: 'debug' })],
};
```
#### `'warning' (default)`
##### `'warning' (default)`
**webpack.config.js**
```js
[
new CopyWebpackPlugin(
[ ...patterns ],
{ debug: true }
)
]
module.exports = {
plugins: [new CopyPlugin([...patterns], { debug: true })],
};
```
### `ignore`
#### `ignore`
**webpack.config.js**
```js
[
new CopyWebpackPlugin(
[ ...patterns ],
{ ignore: [ '*.js', '*.css' ] }
)
]
module.exports = {
plugins: [new CopyPlugin([...patterns], { ignore: ['*.js', '*.css'] })],
};
```
### `context`
#### `context`
**webpack.config.js**
```js
[
new CopyWebpackPlugin(
[ ...patterns ],
{ context: '/app' }
)
]
module.exports = {
plugins: [new CopyPlugin([...patterns], { context: '/app' })],
};
```
### `copyUnmodified`
#### `copyUnmodified`

@@ -388,65 +454,32 @@ > ℹ️ By default, we only copy **modified** files during a `webpack --watch` or `webpack-dev-server` build. Setting this option to `true` will copy all files.

**webpack.config.js**
```js
[
new CopyWebpackPlugin(
[ ...patterns ],
{ copyUnmodified: true }
)
]
module.exports = {
plugins: [new CopyPlugin([...patterns], { copyUnmodified: true })],
};
```
<h2 align="center">Maintainers</h2>
## Contributing
<table>
<tbody>
<tr>
<td align="center">
<a href="https://github.com/bebraw">
<img width="150" height="150" src="https://github.com/bebraw.png?v=3&s=150">
</br>
Juho Vepsäläinen
</a>
</td>
<td align="center">
<a href="https://github.com/d3viant0ne">
<img width="150" height="150" src="https://github.com/d3viant0ne.png?v=3&s=150">
</br>
Joshua Wiens
</a>
</td>
<td align="center">
<a href="https://github.com/michael-ciniawsky">
<img width="150" height="150" src="https://github.com/michael-ciniawsky.png?v=3&s=150">
</br>
Michael Ciniawsky
</a>
</td>
<td align="center">
<a href="https://github.com/evilebottnawi">
<img width="150" height="150" src="https://github.com/evilebottnawi.png?v=3&s=150">
</br>
Alexander Krasnoyarov
</a>
</td>
</tr>
<tbody>
</table>
Please take a moment to read our contributing guidelines if you haven't yet done so.
[CONTRIBUTING](./.github/CONTRIBUTING.md)
## License
[MIT](./LICENSE)
[npm]: https://img.shields.io/npm/v/copy-webpack-plugin.svg
[npm-url]: https://npmjs.com/package/copy-webpack-plugin
[node]: https://img.shields.io/node/v/copy-webpack-plugin.svg
[node-url]: https://nodejs.org
[deps]: https://david-dm.org/webpack-contrib/copy-webpack-plugin.svg
[deps-url]: https://david-dm.org/webpack-contrib/copy-webpack-plugin
[test]: https://secure.travis-ci.org/webpack-contrib/copy-webpack-plugin.svg
[test-url]: http://travis-ci.org/webpack-contrib/copy-webpack-plugin
[tests]: https://secure.travis-ci.org/webpack-contrib/copy-webpack-plugin.svg
[tests-url]: http://travis-ci.org/webpack-contrib/copy-webpack-plugin
[cover]: https://codecov.io/gh/webpack-contrib/copy-webpack-plugin/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack-contrib/copy-webpack-plugin
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
[chat-url]: https://gitter.im/webpack/webpack
[size]: https://packagephobia.now.sh/badge?p=copy-webpack-plugin
[size-url]: https://packagephobia.now.sh/result?p=copy-webpack-plugin
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc