With Angular-cli the builded filename is main.[hash].bundle.js when use ng build -prod
Is it possible to remove the hash form this filename. So just main.bundle.js
?
It's now supported via a command option as of beta.25.
This allows the output filename hashes to be configured during a build via a new build command option
--output-hashing
. There are four possible values:
none
: no hashing performed
media
: only add hashes to files processed via [url|file]-loaders
bundles
: only add hashes to the output bundles
all
: add hashes to both media and bundlesnone is the default for the development target. all is the default for the production target.
More details here.
I added the following script element for production build in the package.json file.
"scripts": {
"prod" : "ng build --prod --output-hashing=none --base-href=./"
}
then running
npm run prod
would build the dist folder without hash and also includes the ./ as base-href so that files are loaded relative to current directory.
As per my understanding the hash
is used for production build so that one wont run into browser cache issues, and the users wont have to clear cache before using the new deployment.
I doubt that angular-cli
team would give us an option to configure that, we have to wait to check that.
Meanwhile if you want to customize your build process you may build the webpack config yourself.
Also, the CLI team has indicated that there will be a few webpack plugins which will help in creating own webpack configuration. Checkout here.
More details here, WEBPACK: AN INTRODUCTION.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With