Socket
Socket
Sign inDemoInstall

copy-webpack-plugin

Package Overview
Dependencies
Maintainers
6
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 6.3.0 to 6.3.1

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [6.3.1](https://github.com/webpack-contrib/copy-webpack-plugin/compare/v6.3.0...v6.3.1) (2020-11-13)
### Bug Fixes
* watching ([#555](https://github.com/webpack-contrib/copy-webpack-plugin/issues/555)) ([b996923](https://github.com/webpack-contrib/copy-webpack-plugin/commit/b9969230321df68ed235ed1861729837f234750e))
## [6.3.0](https://github.com/webpack-contrib/copy-webpack-plugin/compare/v6.2.1...v6.3.0) (2020-11-03)

@@ -7,0 +14,0 @@

2

dist/cjs.js
"use strict";
const plugin = require('./index');
const plugin = require("./index");
module.exports = plugin.default;

@@ -48,3 +48,3 @@ "use strict";

} = // eslint-disable-next-line global-require
_webpack.default.sources || require('webpack-sources');
_webpack.default.sources || require("webpack-sources");

@@ -56,4 +56,4 @@ const template = /(\[ext\])|(\[name\])|(\[path\])|(\[folder\])|(\[emoji(?::(\d+))?\])|(\[(?:([^:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\])|(\[\d+\])/;

(0, _schemaUtils.validate)(_options.default, options, {
name: 'Copy Plugin',
baseDataPath: 'options'
name: "Copy Plugin",
baseDataPath: "options"
});

@@ -103,3 +103,3 @@ this.patterns = options.patterns;

static async runPattern(compiler, compilation, logger, cache, inputPattern, index) {
const pattern = typeof inputPattern === 'string' ? {
const pattern = typeof inputPattern === "string" ? {
from: inputPattern

@@ -110,8 +110,8 @@ } : { ...inputPattern

pattern.from = _path.default.normalize(pattern.from);
pattern.to = _path.default.normalize(typeof pattern.to !== 'undefined' ? pattern.to : '');
pattern.to = _path.default.normalize(typeof pattern.to !== "undefined" ? pattern.to : "");
pattern.compilerContext = compiler.context;
pattern.context = _path.default.normalize(typeof pattern.context !== 'undefined' ? !_path.default.isAbsolute(pattern.context) ? _path.default.join(pattern.compilerContext, pattern.context) : pattern.context : pattern.compilerContext);
pattern.context = _path.default.normalize(typeof pattern.context !== "undefined" ? !_path.default.isAbsolute(pattern.context) ? _path.default.join(pattern.compilerContext, pattern.context) : pattern.context : pattern.compilerContext);
logger.log(`starting to process a pattern from '${pattern.from}' using '${pattern.context}' context to '${pattern.to}'...`);
const isToDirectory = _path.default.extname(pattern.to) === '' || pattern.to.slice(-1) === _path.default.sep;
const isToDirectory = _path.default.extname(pattern.to) === "" || pattern.to.slice(-1) === _path.default.sep;

@@ -124,11 +124,11 @@ switch (true) {

case template.test(pattern.to):
pattern.toType = 'template';
pattern.toType = "template";
break;
case isToDirectory:
pattern.toType = 'dir';
pattern.toType = "dir";
break;
default:
pattern.toType = 'file';
pattern.toType = "file";
}

@@ -155,6 +155,6 @@

if (stats.isDirectory()) {
pattern.fromType = 'dir';
pattern.fromType = "dir";
logger.debug(`determined '${pattern.absoluteFrom}' is a directory`);
} else if (stats.isFile()) {
pattern.fromType = 'file';
pattern.fromType = "file";
logger.debug(`determined '${pattern.absoluteFrom}' is a file`);

@@ -182,3 +182,3 @@ } else {

switch (pattern.fromType) {
case 'dir':
case "dir":
compilation.contextDependencies.add(pattern.absoluteFrom);

@@ -189,6 +189,6 @@ logger.debug(`added '${pattern.absoluteFrom}' as a context dependency`);

pattern.context = pattern.absoluteFrom;
pattern.glob = _path.default.posix.join(_fastGlob.default.escapePath((0, _normalizePath.default)(_path.default.resolve(pattern.absoluteFrom))), '**/*');
pattern.absoluteFrom = _path.default.join(pattern.absoluteFrom, '**/*');
pattern.glob = _path.default.posix.join(_fastGlob.default.escapePath((0, _normalizePath.default)(_path.default.resolve(pattern.absoluteFrom))), "**/*");
pattern.absoluteFrom = _path.default.join(pattern.absoluteFrom, "**/*");
if (typeof pattern.globOptions.dot === 'undefined') {
if (typeof pattern.globOptions.dot === "undefined") {
pattern.globOptions.dot = true;

@@ -201,3 +201,3 @@ }

case 'file':
case "file":
compilation.fileDependencies.add(pattern.absoluteFrom);

@@ -210,3 +210,3 @@ logger.debug(`added '${pattern.absoluteFrom}' as a file dependency`);

if (typeof pattern.globOptions.dot === 'undefined') {
if (typeof pattern.globOptions.dot === "undefined") {
pattern.globOptions.dot = true;

@@ -227,3 +227,3 @@ }

pattern.fromType = 'glob';
pattern.fromType = "glob";
pattern.glob = _path.default.isAbsolute(pattern.fromOrigin) ? pattern.fromOrigin : _path.default.posix.join(_fastGlob.default.escapePath((0, _normalizePath.default)(_path.default.resolve(pattern.context))), pattern.fromOrigin);

@@ -294,3 +294,3 @@ /* eslint-enable no-param-reassign */

const relativeFrom = pattern.flatten ? _path.default.basename(absoluteFilename) : _path.default.relative(pattern.context, absoluteFilename);
let filename = pattern.toType === 'dir' ? _path.default.join(pattern.to, relativeFrom) : pattern.to;
let filename = pattern.toType === "dir" ? _path.default.join(pattern.to, relativeFrom) : pattern.to;

@@ -325,3 +325,3 @@ if (_path.default.isAbsolute(filename)) {

if (pattern.fromType === 'glob') {
if (pattern.fromType === "glob") {
compilation.fileDependencies.add(absoluteFilename);

@@ -390,3 +390,3 @@ logger.debug(`added '${absoluteFilename}' as a file dependency`);

try {
snapshot = await CopyPlugin.createSnapshot(compilation, startTime, sourceFilename);
snapshot = await CopyPlugin.createSnapshot(compilation, startTime, absoluteFilename);
} catch (error) {

@@ -425,6 +425,6 @@ compilation.errors.push(error);

transform: pattern.transform,
contentHash: _crypto.default.createHash('md4').update(buffer).digest('hex'),
contentHash: _crypto.default.createHash("md4").update(buffer).digest("hex"),
index
};
const cacheKeys = `transform|${(0, _serializeJavascript.default)(typeof pattern.cacheTransform.keys === 'function' ? await pattern.cacheTransform.keys(defaultCacheKeys, absoluteFilename) : { ...defaultCacheKeys,
const cacheKeys = `transform|${(0, _serializeJavascript.default)(typeof pattern.cacheTransform.keys === "function" ? await pattern.cacheTransform.keys(defaultCacheKeys, absoluteFilename) : { ...defaultCacheKeys,
...pattern.cacheTransform.keys

@@ -440,4 +440,4 @@ })}`;

} else {
cacheDirectory = pattern.cacheTransform.directory ? pattern.cacheTransform.directory : typeof pattern.cacheTransform === 'string' ? pattern.cacheTransform : (0, _findCacheDir.default)({
name: 'copy-webpack-plugin'
cacheDirectory = pattern.cacheTransform.directory ? pattern.cacheTransform.directory : typeof pattern.cacheTransform === "string" ? pattern.cacheTransform : (0, _findCacheDir.default)({
name: "copy-webpack-plugin"
}) || _os.default.tmpdir();

@@ -481,3 +481,3 @@ let cached;

if (pattern.toType === 'template') {
if (pattern.toType === "template") {
logger.log(`interpolating template '${filename}' for '${sourceFilename}'...`); // If it doesn't have an extension, remove it from the pattern

@@ -488,3 +488,3 @@ // ie. [name].[ext] or [name][ext] both become [name]

// eslint-disable-next-line no-param-reassign
result.filename = result.filename.replace(/\.?\[ext]/g, '');
result.filename = result.filename.replace(/\.?\[ext]/g, "");
} // eslint-disable-next-line no-param-reassign

@@ -535,7 +535,7 @@

compiler.hooks.thisCompilation.tap(pluginName, compilation => {
const logger = compilation.getLogger('copy-webpack-plugin');
const cache = compilation.getCache ? compilation.getCache('CopyWebpackPlugin') : // eslint-disable-next-line no-undefined
const logger = compilation.getLogger("copy-webpack-plugin");
const cache = compilation.getCache ? compilation.getCache("CopyWebpackPlugin") : // eslint-disable-next-line no-undefined
undefined;
compilation.hooks.additionalAssets.tapAsync('copy-webpack-plugin', async callback => {
logger.log('starting to add additional assets...');
compilation.hooks.additionalAssets.tapAsync("copy-webpack-plugin", async callback => {
logger.log("starting to add additional assets...");
let assets;

@@ -564,3 +564,3 @@

if (typeof compilation.emitAsset !== 'function') {
if (typeof compilation.emitAsset !== "function") {
// eslint-disable-next-line no-param-reassign

@@ -607,3 +607,3 @@ compilation.assets[filename] = source;

});
logger.log('finished to adding additional assets');
logger.log("finished to adding additional assets");
callback();

@@ -614,7 +614,7 @@ });

compilation.hooks.statsPrinter.tap(pluginName, stats => {
stats.hooks.print.for('asset.info.copied').tap('copy-webpack-plugin', (copied, {
stats.hooks.print.for("asset.info.copied").tap("copy-webpack-plugin", (copied, {
green,
formatFlag
}) => // eslint-disable-next-line no-undefined
copied ? green(formatFlag('copied')) : undefined);
copied ? green(formatFlag("copied")) : undefined);
});

@@ -621,0 +621,0 @@ }

{
"name": "copy-webpack-plugin",
"version": "6.3.0",
"version": "6.3.1",
"description": "Copy files && directories with webpack",

@@ -64,3 +64,3 @@ "license": "MIT",

"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^26.6.1",
"babel-jest": "^26.6.3",
"chokidar": "^3.4.3",

@@ -70,3 +70,3 @@ "cross-env": "^7.0.2",

"del-cli": "^3.0.1",
"eslint": "^7.12.1",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.15.0",

@@ -77,4 +77,4 @@ "eslint-plugin-import": "^2.22.1",

"is-gzip": "^2.0.0",
"jest": "^26.6.1",
"lint-staged": "^10.4.2",
"jest": "^26.6.3",
"lint-staged": "^10.5.1",
"memfs": "^3.2.0",

@@ -85,3 +85,3 @@ "mkdirp": "^1.0.4",

"standard-version": "^9.0.0",
"webpack": "^5.3.2"
"webpack": "^5.4.0"
},

@@ -88,0 +88,0 @@ "keywords": [

@@ -33,3 +33,3 @@ <div align="center">

```js
const CopyPlugin = require('copy-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");

@@ -40,4 +40,4 @@ module.exports = {

patterns: [
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
{ from: "source", to: "dest" },
{ from: "other", to: "public" },
],

@@ -62,3 +62,3 @@ }),

```js
const CopyPlugin = require('copy-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");

@@ -69,4 +69,4 @@ module.exports = {

patterns: [
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
{ from: "source", to: "dest" },
{ from: "other", to: "public" },
],

@@ -118,14 +118,14 @@ options: {

patterns: [
'relative/path/to/file.ext',
'relative/path/to/dir',
path.resolve(__dirname, 'src', 'file.ext'),
path.resolve(__dirname, 'src', 'dir'),
'**/*',
"relative/path/to/file.ext",
"relative/path/to/dir",
path.resolve(__dirname, "src", "file.ext"),
path.resolve(__dirname, "src", "dir"),
"**/*",
{
from: '**/*',
from: "**/*",
},
// If absolute path is a `glob` we replace backslashes with forward slashes, because only forward slashes can be used in the `glob`
path.posix.join(
path.resolve(__dirname, 'src').replace(/\\/g, '/'),
'*.txt'
path.resolve(__dirname, "src").replace(/\\/g, "/"),
"*.txt"
),

@@ -148,3 +148,3 @@ ],

{
from: path.resolve(__dirname, 'file.txt'),
from: path.resolve(__dirname, "file.txt"),
},

@@ -168,4 +168,4 @@ ],

from: path.posix.join(
path.resolve(__dirname, 'fixtures').replace(/\\/g, '/'),
'*.txt'
path.resolve(__dirname, "fixtures").replace(/\\/g, "/"),
"*.txt"
),

@@ -201,12 +201,12 @@ },

{
from: '**/*',
to: 'relative/path/to/dest/',
from: "**/*",
to: "relative/path/to/dest/",
},
{
from: '**/*',
to: '/absolute/path/to/dest/',
from: "**/*",
to: "/absolute/path/to/dest/",
},
{
from: '**/*',
to: '[path][name].[contenthash].[ext]',
from: "**/*",
to: "[path][name].[contenthash].[ext]",
},

@@ -238,5 +238,5 @@ ],

{
from: 'src/*.txt',
to: 'dest/',
context: 'app/',
from: "src/*.txt",
to: "dest/",
context: "app/",
},

@@ -279,7 +279,7 @@ ],

{
from: 'public/**/*',
from: "public/**/*",
globOptions: {
dot: true,
gitignore: true,
ignore: ['**/file.*', '**/ignored-directory/**'],
ignore: ["**/file.*", "**/ignored-directory/**"],
},

@@ -303,3 +303,3 @@ },

```js
const fs = require('fs').promise;
const fs = require("fs").promise;

@@ -311,3 +311,3 @@ module.exports = {

{
from: 'public/**/*',
from: "public/**/*",
filter: async (resourcePath) => {

@@ -317,3 +317,3 @@ const data = await fs.promises.readFile(resourcePath);

if (content === 'my-custom-content') {
if (content === "my-custom-content") {
return false;

@@ -357,5 +357,5 @@ }

{
from: 'path/to/file.txt',
to: 'directory/with/extension.ext',
toType: 'dir',
from: "path/to/file.txt",
to: "directory/with/extension.ext",
toType: "dir",
},

@@ -378,5 +378,5 @@ ],

{
from: 'path/to/file.txt',
to: 'file/without/extension',
toType: 'file',
from: "path/to/file.txt",
to: "file/without/extension",
toType: "file",
},

@@ -399,5 +399,5 @@ ],

{
from: 'src/',
to: 'dest/[name].[hash].[ext]',
toType: 'template',
from: "src/",
to: "dest/[name].[hash].[ext]",
toType: "template",
},

@@ -425,4 +425,4 @@ ],

{
from: 'src/**/*',
to: 'dest/',
from: "src/**/*",
to: "dest/",
force: true,

@@ -453,4 +453,4 @@ },

{
from: 'src/**/*',
to: 'dest/',
from: "src/**/*",
to: "dest/",
flatten: true,

@@ -479,4 +479,4 @@ },

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
// The `content` argument is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `content.toString()`

@@ -502,4 +502,4 @@ // The `absoluteFrom` argument is a `String`, it is absolute path from where the file is being copied

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
transform(content, path) {

@@ -535,4 +535,4 @@ return Promise.resolve(optimize(content));

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
transform(content, path) {

@@ -561,4 +561,4 @@ return optimize(content);

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
transform(content, path) {

@@ -568,3 +568,3 @@ return optimize(content);

// Should be absolute
cacheTransform: path.resolve(__dirname, 'cache-directory'),
cacheTransform: path.resolve(__dirname, "cache-directory"),
},

@@ -589,4 +589,4 @@ ],

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
transform(content, path) {

@@ -596,7 +596,7 @@ return optimize(content);

cacheTransform: {
directory: path.resolve(__dirname, 'cache-directory'),
directory: path.resolve(__dirname, "cache-directory"),
keys: {
// May be useful for invalidating cache based on external values
// For example, you can invalid cache based on `process.version` - { node: process.version }
key: 'value',
key: "value",
},

@@ -623,4 +623,4 @@ },

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
transform(content, path) {

@@ -630,3 +630,3 @@ return optimize(content);

cacheTransform: {
directory: path.resolve(__dirname, 'cache-directory'),
directory: path.resolve(__dirname, "cache-directory"),
keys: (defaultCacheKeys, absoluteFrom) => {

@@ -658,4 +658,4 @@ const keys = getCustomCacheInvalidationKeysSync();

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
transform(content, path) {

@@ -665,3 +665,3 @@ return optimize(content);

cacheTransform: {
directory: path.resolve(__dirname, 'cache-directory'),
directory: path.resolve(__dirname, "cache-directory"),
keys: async (defaultCacheKeys, absoluteFrom) => {

@@ -702,6 +702,6 @@ const keys = await getCustomCacheInvalidationKeysAsync();

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
transformPath(targetPath, absolutePath) {
return 'newPath';
return "newPath";
},

@@ -723,6 +723,6 @@ },

{
from: 'src/*.png',
to: 'dest/',
from: "src/*.png",
to: "dest/",
transformPath(targetPath, absolutePath) {
return Promise.resolve('newPath');
return Promise.resolve("newPath");
},

@@ -749,3 +749,3 @@ },

{
from: path.resolve(__dirname, 'missing-file.txt'),
from: path.resolve(__dirname, "missing-file.txt"),
noErrorOnMissing: true,

@@ -805,3 +805,3 @@ },

{
from: 'src/directory-nested/**/*',
from: "src/directory-nested/**/*",
},

@@ -831,4 +831,4 @@ ],

{
from: '**/*',
context: path.resolve(__dirname, 'src', 'directory-nested'),
from: "**/*",
context: path.resolve(__dirname, "src", "directory-nested"),
},

@@ -858,3 +858,3 @@ ],

{
from: path.resolve(__dirname, 'src', 'directory-nested'),
from: path.resolve(__dirname, "src", "directory-nested"),
},

@@ -884,4 +884,4 @@ ],

{
from: '**/*',
context: path.resolve(__dirname, 'src', 'directory-nested'),
from: "**/*",
context: path.resolve(__dirname, "src", "directory-nested"),
},

@@ -911,5 +911,5 @@ ],

__dirname,
'src',
'directory-nested',
'nested-file.txt'
"src",
"directory-nested",
"nested-file.txt"
),

@@ -939,4 +939,4 @@ },

{
from: 'nested-file.txt',
context: path.resolve(__dirname, 'src', 'directory-nested'),
from: "nested-file.txt",
context: path.resolve(__dirname, "src", "directory-nested"),
},

@@ -966,4 +966,4 @@ ],

from: path.posix.join(
path.resolve(__dirname, 'src').replace(/\\/g, '/'),
'**/*'
path.resolve(__dirname, "src").replace(/\\/g, "/"),
"**/*"
),

@@ -973,5 +973,5 @@ globOptions: {

// Ignore all `txt` files
'**/*.txt',
"**/*.txt",
// Ignore all files in all subdirectories
'**/subdir/**',
"**/subdir/**",
],

@@ -978,0 +978,0 @@ },

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