问题
I need to make Angular ignore a certain js
file during the optimization phase (so that it's not optimized/minified) in prod
build. For this purpose the @angular-builders
package seemed like a viable solution.
I setup the angular.json
config as follows:
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./extended-webpack.config.js",
"mergeStrategies": {
"optimization": "replace"
}
},
The build configurations
are as follows:
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
The rest of the configuration stays the same as for normal use-cases.
The extended-webpack.config.js
looks like following:
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
optimization: {
minimizer: [
new TerserPlugin({
exclude: ['./node_modules/<lib>/main.js']
}),
],
}
};
From what I see in the build the library is still minimized from the original version. Is this configuration correct for what I want to do?
来源:https://stackoverflow.com/questions/54607569/angular-builders-ignore-certain-script-during-in-the-optimisation-phase