Lpp*_*Edd 2 single-page-application typescript ecmascript-6 webpack angular
使用自定义 Angular Builder,我尝试将整个模块排除在缩小/优化之外。
Webpack.md文件说
类型
:String|RegExp|Array 默认值:undefined要排除的文件。
我可以使用此设置来排除整个目录(即节点模块)吗?
当前的代码是
export default class CustomizeTerserBrowserBuilder extends BrowserBuilder {
public buildWebpackConfig(root: any, projectRoot: any, host: any, options: any): any {
const webpackConfig = super.buildWebpackConfig(root, projectRoot, host, options);
if (
webpackConfig.optimization &&
webpackConfig.optimization.minimizer &&
Array.isArray(webpackConfig.optimization.minimizer)
) {
const terserPlugin = (webpackConfig.optimization.minimizer as any[]).find(
minimizer => minimizer instanceof TerserPlugin
);
if (terserPlugin) {
terserPlugin.options.exclude = [/node_modules/];
}
}
return webpackConfig;
}
}
Run Code Online (Sandbox Code Playgroud)
也许你正在寻找这个
module.exports = {
optimization: {
minimizer: [
new TerserPlugin({
exclude: /node_modules/,
}),
],
},
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6269 次 |
| 最近记录: |