Is there anyway to obfuscate a public JavaScript file in angular(not external libraries)?

Viewed 601

I have an angular project in which, I need to keep a file publicly accessible and it should get obfuscated at the time of production build.

I have tried the third-party libraries to do the job, but I need to run a separate npm script to do it, is there any way that angular(web-pack) can take care?

"build:prod": "yarn curl:prod && node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --c=production",

Prod build did not help. Thanks.

1 Answers

Extend your package.json with a "prod" script:

 "scripts": {
    ...
    "build:prod": "ng build --prod --sourceMap false",
    ...
  },

And then just run it: npm run build:prod

Related