Skip to content

Commit

Permalink
chore(deps): update copy-webpack-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
bartholomej committed Oct 21, 2020
1 parent ecac861 commit 96d4b6a
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 410 deletions.
31 changes: 16 additions & 15 deletions config/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

// const version = process.env.npm_package_version;
Expand Down Expand Up @@ -41,19 +40,21 @@ module.exports = function (options) {
filename: '[name].css',
chunkFilename: '[id].css'
}),
new CopyWebpackPlugin([
// {
// from: 'src/manifest-common.json',
// to: 'manifest.json',
// transform: function (content, path) {
// var manifest = JSON.parse(content.toString());
// manifest.version = version;
// return JSON.stringify(manifest, null, 2);
// }
// },
{ from: 'src/_locales/', to: '_locales' },
{ from: 'src/images/', to: 'images' }
])
new CopyPlugin({
patterns: [
// {
// from: 'src/manifest-common.json',
// to: 'manifest.json',
// transform: function (content, path) {
// var manifest = JSON.parse(content.toString());
// manifest.version = version;
// return JSON.stringify(manifest, null, 2);
// }
// },
{ from: 'src/_locales/', to: '_locales' },
{ from: 'src/images/', to: 'images' }
]
})
]
};
};
34 changes: 18 additions & 16 deletions config/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const webpack = require('webpack');
const { merge } = require('webpack-merge');
const ExtensionReloader = require('webpack-extension-reloader');
const commonConfig = require('./webpack.common.js');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');

const version = process.env.npm_package_version;

Expand Down Expand Up @@ -30,22 +30,24 @@ module.exports = function (options) {
new webpack.DefinePlugin({
BROWSER: JSON.stringify('chrome')
}),
new CopyWebpackPlugin([
{
from: 'src/manifest-common.json',
to: 'manifest.json',
transform: function (content, path) {
const contentSecurityPolicy = "script-src 'self' 'unsafe-eval'; object-src 'self'";
var manifest = JSON.parse(content.toString());
manifest.version = version;
// Inject security policy only for dev
// because Chrome reloader is using eval
manifest['content_security_policy'] = contentSecurityPolicy;
var manifestObj = Object.assign(manifest, backgroundManifest);
return JSON.stringify(manifestObj, null, 2);
new CopyPlugin({
patterns: [
{
from: 'src/manifest-common.json',
to: 'manifest.json',
transform: function (content, path) {
const contentSecurityPolicy = "script-src 'self' 'unsafe-eval'; object-src 'self'";
var manifest = JSON.parse(content.toString());
manifest.version = version;
// Inject security policy only for dev
// because Chrome reloader is using eval
manifest['content_security_policy'] = contentSecurityPolicy;
var manifestObj = Object.assign(manifest, backgroundManifest);
return JSON.stringify(manifestObj, null, 2);
}
}
}
])
]
})
]
});
};
35 changes: 15 additions & 20 deletions config/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const ZipPlugin = require('zip-webpack-plugin');

const commonConfig = require('./webpack.common.js');
Expand All @@ -21,18 +21,20 @@ module.exports = (options) => {
new webpack.DefinePlugin({
BROWSER: JSON.stringify(target)
}),
new CopyWebpackPlugin([
{
from: 'src/manifest-common.json',
to: 'manifest.json',
transform: (content, path) => {
var manifest = JSON.parse(content.toString());
manifest.version = version;
var manifestObj = Object.assign(manifest, browserSpecificProperties);
return JSON.stringify(manifestObj, null, 2);
new CopyPlugin({
patterns: [
{
from: 'src/manifest-common.json',
to: 'manifest.json',
transform: (content, path) => {
var manifest = JSON.parse(content.toString());
manifest.version = version;
var manifestObj = Object.assign(manifest, browserSpecificProperties);
return JSON.stringify(manifestObj, null, 2);
}
}
}
]),
]
}),
new ZipPlugin({
// OPTIONAL: defaults to the Webpack output path (above)
// can be relative (to Webpack output path) or absolute
Expand Down Expand Up @@ -82,14 +84,7 @@ module.exports = (options) => {
zipOptions: {
forceZip64Format: false
}
}),
// Create build zip with version
new CopyWebpackPlugin([
{
from: './zip/' + target + '.zip',
to: '../zip/' + target + '-v' + version + '.zip'
}
])
})
]
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/chrome": "0.0.125",
"@types/node": "^14.14.1",
"awesome-typescript-loader": "^5.2.1",
"copy-webpack-plugin": "^5.1.2",
"copy-webpack-plugin": "^6.1.2",
"css-loader": "^5.0.0",
"exports-loader": "^1.1.1",
"imports-loader": "^1.2.0",
Expand Down
Loading

0 comments on commit 96d4b6a

Please sign in to comment.