I have latest angular project. I got two different npm commands in package.json
. Both of these commands executes ng build --output-path=...
and generate build files in different locations using different --output-path
flags. Is there any flag or any property that I can apply in angular.json
so that build files have different hashes for these two different npm commands? Something like hash prefix. So that index.html
files are not identical since they import different js files.
The reason behind that is that: js files are cached. These two npm command is two different deployment (one for ssr one for csr) and I need to cache js files without cache overleaping for these two deployments (need different names).
Try adding the --output-hashing
param on the build command itself, eg:
ng build --output-path=... --output-hashing=bundles
The values are either all
, bundles
, media
or none
.
This will generate angular bundles with a hash like this: main.62beb1fb93041eb44194.js
, and the index.html will link to those hashed versions.
Docs: https://angular.io/cli/build#options
You can also add the parameter into angular.json
like this:
"build": {
...
"options": {
...
"outputHashing": "all",
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.