From 7ca3711ad3e3969f12343dd07f527361dd53b42d Mon Sep 17 00:00:00 2001 From: sienori Date: Tue, 6 Apr 2021 17:52:14 +0900 Subject: [PATCH] Update copy-webpack-plugin --- package.json | 2 +- webpack.config.dist.js | 86 +++++++++++++++++++++--------------------- webpack.utils.js | 60 +++++++++++++++-------------- 3 files changed, 77 insertions(+), 71 deletions(-) diff --git a/package.json b/package.json index eb5cbd5..b267a31 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "babel-loader": "^8.0.0-beta.3", "babel-plugin-transform-class-properties": "^6.24.1", "clean-webpack-plugin": "^0.1.19", - "copy-webpack-plugin": "^5.1.1", + "copy-webpack-plugin": "^6.4.1", "css-loader": "^3.5.3", "html-webpack-plugin": "^3.2.0", "mini-css-extract-plugin": "^0.5.0", diff --git a/webpack.config.dist.js b/webpack.config.dist.js index 3709998..6cd5dc9 100644 --- a/webpack.config.dist.js +++ b/webpack.config.dist.js @@ -130,48 +130,50 @@ module.exports = [ entry: { other: path.resolve(__dirname, `src/background/background.js`) }, output: getOutput("copiedSource", config.tempDirectory), plugins: [ - new CopyWebpackPlugin([ - { - from: `src`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/src/`) - }, - { - from: `babel.config.js`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/babel.config.js`) - }, - { - from: `config.json`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/config.json`) - }, - { - from: `LICENSE`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/LICENSE`) - }, - { - from: `package.json`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/package.json`) - }, - { - from: `package-lock.json`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/package-lock.json`) - }, - { - from: `README.md`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/README.md`) - }, - { - from: `webpack.config.dev.js`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/webpack.config.dev.js`) - }, - { - from: `webpack.config.dist.js`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/webpack.config.dist.js`) - }, - { - from: `webpack.utils.js`, - to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/webpack.utils.js`) - } - ]), + new CopyWebpackPlugin({ + patterns: [ + { + from: `src`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/src/`) + }, + { + from: `babel.config.js`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/babel.config.js`) + }, + { + from: `config.json`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/config.json`) + }, + { + from: `LICENSE`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/LICENSE`) + }, + { + from: `package.json`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/package.json`) + }, + { + from: `package-lock.json`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/package-lock.json`) + }, + { + from: `README.md`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/README.md`) + }, + { + from: `webpack.config.dev.js`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/webpack.config.dev.js`) + }, + { + from: `webpack.config.dist.js`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/webpack.config.dist.js`) + }, + { + from: `webpack.utils.js`, + to: path.resolve(__dirname, `${config.tempDirectory}/copiedSource/webpack.utils.js`) + } + ] + }), getZipPlugin(`copiedSource-${config.extName}-${ffExtVersion}`, config.distDirectory, "other/") ] } diff --git a/webpack.utils.js b/webpack.utils.js index d6d0ac2..685e094 100644 --- a/webpack.utils.js +++ b/webpack.utils.js @@ -40,37 +40,41 @@ const getEntry = (sourceDir = "src") => { }; const getCopyPlugins = (browserDir, outputDir = "dev", sourceDir = "src") => [ - new CopyWebpackPlugin([ - { - from: `${sourceDir}/icons`, - to: path.resolve(__dirname, `${outputDir}/${browserDir}/icons`) - }, - { - from: `${sourceDir}/_locales`, - to: path.resolve(__dirname, `${outputDir}/${browserDir}/_locales`) - }, - { - from: `${sourceDir}/manifest-chrome.json`, - to: path.resolve(__dirname, `${outputDir}/${browserDir}/manifest.json`) - } - ]) + new CopyWebpackPlugin({ + patterns: [ + { + from: `${sourceDir}/icons`, + to: path.resolve(__dirname, `${outputDir}/${browserDir}/icons`) + }, + { + from: `${sourceDir}/_locales`, + to: path.resolve(__dirname, `${outputDir}/${browserDir}/_locales`) + }, + { + from: `${sourceDir}/manifest-chrome.json`, + to: path.resolve(__dirname, `${outputDir}/${browserDir}/manifest.json`) + } + ] + }) ]; const getFirefoxCopyPlugins = (browserDir, outputDir = "dev", sourceDir = "src") => [ - new CopyWebpackPlugin([ - { - from: `${sourceDir}/icons`, - to: path.resolve(__dirname, `${outputDir}/${browserDir}/icons`) - }, - { - from: `${sourceDir}/_locales`, - to: path.resolve(__dirname, `${outputDir}/${browserDir}/_locales`) - }, - { - from: `${sourceDir}/manifest-firefox.json`, - to: path.resolve(__dirname, `${outputDir}/${browserDir}/manifest.json`) - } - ]) + new CopyWebpackPlugin({ + patterns: [ + { + from: `${sourceDir}/icons`, + to: path.resolve(__dirname, `${outputDir}/${browserDir}/icons`) + }, + { + from: `${sourceDir}/_locales`, + to: path.resolve(__dirname, `${outputDir}/${browserDir}/_locales`) + }, + { + from: `${sourceDir}/manifest-firefox.json`, + to: path.resolve(__dirname, `${outputDir}/${browserDir}/manifest.json`) + } + ] + }) ]; const getZipPlugin = (browserDir, outputDir = "dist", exclude = "") =>