gpt4 book ai didi

webpack-5 - 如何将简洁的 webpack 插件迁移到 webpack v5

转载 作者:行者123 更新时间:2023-12-05 06:48:34 29 4
gpt4 key购买 nike

If you are using webpack v5 or above you do not need to install this plugin. Webpack v5 comes with the latest terser-webpack-plugin out of the box.

我将使用 webpack v5,所以根据文档,我删除了 terser:npm uninstall terser-webpack-plugin。但我不确定如何迁移为 webpack v4 + TerserPlugin 设置的以下设置:

optimization: {
minimizer: [
new TerserPlugin({
sourceMap: true,
terserOptions: {
output: {
comments: /^!/,
},
},
extractComments: false,
}),
],
},

我无法在线找到该文档。请问有人可以帮忙吗?

最佳答案

我正在使用以下 TerserPlugin 配置,它适用于 webpack v5!

  optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
test: /\.js(\?.*)?$/i, // you should add this property
extractComments: false,
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log', 'console.info'], // Delete console
},
},
}),
],
},

关于webpack-5 - 如何将简洁的 webpack 插件迁移到 webpack v5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66801321/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com