在js
构建的优化阶段,我需要使Angular忽略某个prod
文件(这样就不会对其进行优化/缩小)。为此,@angular-builders
软件包似乎是一个可行的解决方案。
我按如下所示设置angular.json
配置:
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./extended-webpack.config.js",
"mergeStrategies": {
"optimization": "replace"
}
},
内部版本configurations
如下:
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
其余配置与正常使用情况相同。
extended-webpack.config.js
如下所示:
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
optimization: {
minimizer: [
new TerserPlugin({
exclude: ['./node_modules/<lib>/main.js']
}),
],
}
};
根据我在构建中看到的内容,该库仍比原始版本最小化。这种配置对我想要做的正确吗?