@ angular-builders-在优化阶段忽略某些脚本

时间:2019-02-09 15:13:10

标签: angular webpack angular-cli

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']
            }),
        ],
    }
};

根据我在构建中看到的内容,该库仍比原始版本最小化。这种配置对我想要做的正确吗?

0 个答案:

没有答案