-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update webpack to v5 #206
Update webpack to v5 #206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
let { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') | ||
let PnpWebpackPlugin = require('pnp-webpack-plugin') | ||
let { promisify } = require('util') | ||
let escapeRegexp = require('escape-string-regexp') | ||
let OptimizeCss = require('optimize-css-assets-webpack-plugin') | ||
let CssMinimizerPlugin = require('css-minimizer-webpack-plugin') | ||
let { join } = require('path') | ||
let mkdirp = require('mkdirp') | ||
let fs = require('fs') | ||
|
@@ -35,13 +34,9 @@ module.exports = async function getConfig (limitConfig, check, output) { | |
path: output | ||
}, | ||
optimization: { | ||
concatenateModules: !check.disableModuleConcatenation | ||
}, | ||
resolve: { | ||
plugins: [PnpWebpackPlugin] | ||
}, | ||
resolveLoader: { | ||
plugins: [PnpWebpackPlugin.moduleLoader(module)] | ||
concatenateModules: !check.disableModuleConcatenation, | ||
minimize: true, | ||
minimizer: ['...', new CssMinimizerPlugin()] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't fully understand the |
||
}, | ||
module: { | ||
rules: [ | ||
|
@@ -67,14 +62,13 @@ module.exports = async function getConfig (limitConfig, check, output) { | |
] | ||
} | ||
] | ||
}, | ||
plugins: [new OptimizeCss()] | ||
} | ||
} | ||
|
||
if (check.ignore && check.ignore.length > 0) { | ||
let escaped = check.ignore.map(i => escapeRegexp(i)) | ||
let ignorePattern = new RegExp(`^(${escaped.join('|')})($|/)`) | ||
config.externals = (context, request, callback) => { | ||
config.externals = ({ request }, callback) => { | ||
ai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (ignorePattern.test(request)) { | ||
callback(null, 'root a') | ||
} else { | ||
|
@@ -84,6 +78,8 @@ module.exports = async function getConfig (limitConfig, check, output) { | |
} | ||
|
||
if (limitConfig.why) { | ||
if (!config.plugins) config.plugins = [] | ||
|
||
config.plugins.push( | ||
new BundleAnalyzerPlugin({ | ||
openAnalyzer: process.env.NODE_ENV !== 'test', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,11 @@ function getFiles (stats, check) { | |
|
||
return Object.keys(entries) | ||
.reduce((assets, i) => assets.concat(entries[i].assets), []) | ||
.map(i => { | ||
.map(({ name }) => { | ||
if (check.webpackConfig.output && check.webpackConfig.output.path) { | ||
return join(check.webpackConfig.output.path, i) | ||
return join(check.webpackConfig.output.path, name) | ||
} else { | ||
return join(process.cwd(), 'dist', i) | ||
return join(process.cwd(), 'dist', name) | ||
Comment on lines
-34
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was causing Also, I tried to refactor this into a cute ternary arrow function return, but it caused multiple ESLint errors as the rules that conflict with Prettier have not been disabled. |
||
} | ||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this should be forced to
true
like this; it depends if we only want it to automatically happen when themode
isproduction
and notdevelopment
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove it and see the tests changes