Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular-cli - how to change the names of the generated css/js bundle files

I am using angular-cli 1.0.0-beta.24. When I run ng build --production, is there a way to change the name of the generated *.bundle.css and *.bundle.js files?

The default names are: main.[hash].bundle.js, styles.[hash].bundle.css, vendor.[hash].bundle.js and inline.[hash].bundle.js and I would like to change these. Also this should reflect in automatic change of the generated css/script links in index.html.

Thanks in advance.

like image 203
regnauld Avatar asked Dec 29 '16 13:12

regnauld


2 Answers

I think you can remove the hashes by providing --output-hashing none

like image 50
Shobhit Avatar answered Sep 25 '22 04:09

Shobhit


Sadly for now you can't do that.

There is a thread discussing this issue here: https://github.com/angular/angular-cli/issues/1656

According to the team they do not intend to allow customization of the Webpack configuration (Webpack is the tool that generates the transpiled files) anytime soon.

Changing the code in the files will update the [hash] in the vendor and main files but inline and styles will always have the same hash...

Someone in this thread suggested using the following seed which allows you to update the Webpack configuration of your Angular app (and seems to also support AOT and SSR) but I have not tested it to see if it actually works and it is not part of the angular-cli project.

like image 20
Aviram Gabay Avatar answered Sep 22 '22 04:09

Aviram Gabay