Tested Angular 15
npm i -D @angular-builders/custom-webpack@<same-with-angular-ver> webpack-obfuscator
Tested: @angular-builders/custom-webpack@15
and [email protected]
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"customWebpackConfig": {
"path": "./extra-webpack.config.js",
"replaceDuplicatePlugins": true,
"mergeStrategies": {
"module.rules": "prepend"
}
},
...
Create
extra-webpack.config.js
same level with angular.json
'use strict';
const WebpackObfuscator = require('webpack-obfuscator');
module.exports = {
plugins: [
new WebpackObfuscator({
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
identifierNamesGenerator: 'hexadecimal',
numbersToExpressions: false,
renameGlobals: false,
selfDefending: false,
simplify: false,
splitStrings: false,
stringArray: true,
transformObjectKeys: false,
stringArrayCallsTransform: false,
stringArrayEncoding: [],
stringArrayIndexShift: false,
stringArrayRotate: false,
stringArrayShuffle: false,
stringArrayWrappersCount: 0,
stringArrayWrappersChainedCalls: false,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 1,
unicodeEscapeSequence: false,
renamePropertiesMode: 'safe',
renameProperties: false
}, [ '*', '!main.js' ])
]
};
Normal build: node node_modules/@angular/cli/bin/ng build --configuration production