Skip to content

Commit

Permalink
build: migrate to webpack@5
Browse files Browse the repository at this point in the history
  • Loading branch information
rocka committed Nov 21, 2020
1 parent 7fd3f10 commit c0f2e8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion script/webpack.config.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if (isProd) {
} else {
// dev config
cfg.mode = 'development';
cfg.devtool = 'cheap-module-eval-source-map';
cfg.devtool = 'eval-cheap-module-source-map';
cfg.externals = Object.keys(packageJson.dependencies);
cfg.resolve = {
modules: [
Expand Down
21 changes: 11 additions & 10 deletions script/webpack.config.renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ let cfg = {
output: {
filename: '[name].js',
path: absPath('dist'),
// https://github.com/webpack/webpack/issues/6642
globalObject: 'this'
publicPath: ''
},
module: {
rules: [
Expand Down Expand Up @@ -101,13 +100,15 @@ if (isProd) {
]
}
);
// what a heck!
// ref: https://github.com/jantimon/html-webpack-plugin/blob/v3.2.0/index.js#L34
// ref: https://github.com/jantimon/html-webpack-plugin/blob/v3.2.0/index.js#L479
cfg.plugins.find(p => p instanceof HtmlWebpackPlugin).options.meta = [{
'http-equiv': 'Content-Security-Policy',
content: `script-src 'self'; media-src http://localhost:* https://*.vod.126.net; img-src 'self' https://*.music.126.net https://music.163.com`
}];
// https://github.com/jantimon/html-webpack-plugin/blob/v4.5.0/index.js#L74
// https://github.com/jantimon/html-webpack-plugin/blob/v4.5.0/index.js#L766
cfg.plugins.find(p => p instanceof HtmlWebpackPlugin).userOptions.meta = {
viewport: false,
csp: {
'http-equiv': 'Content-Security-Policy',
content: `script-src 'self'; media-src http://localhost:* https://*.vod.126.net; img-src 'self' https://*.music.126.net https://music.163.com`
}
};
cfg.plugins.push(
new MiniCSSExtractPlugin()
);
Expand All @@ -118,7 +119,7 @@ if (isProd) {
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader'] }
);
cfg.devtool = 'cheap-module-eval-source-map';
cfg.devtool = 'eval-cheap-module-source-map';
cfg.output.libraryTarget = 'commonjs2';
cfg.externals = Object.keys(packageJson.dependencies);
cfg.resolve.modules = [
Expand Down

0 comments on commit c0f2e8a

Please sign in to comment.