Add cache busting to
ngx-translate i18n files
The problem: translation files cache is not refreshed after deploy.
ngx-build-plus, this allows to add custom Webpack partial configs.
ngx-build-plusas builder. Replace all instances of
package.jsonto use the new Webpack partial
TranslateHttpLoaderconfig to use the i18n hash.
Build with zero downtime on Angular
The recommended way to have zero downtime it's using dockerized builds with a docker registry service. In case that this isn't possible in your project, here you have a quick fix.
Create this folders on
/dist/nginx(the new production path)
package.json add on
..."prebuild": "rm -rf dist/previousbuild","build": "ng build --prod --source-map --optimization=true --buildOptimizer=true --progress=true","postbuild": "mv dist/nginx dist/previousbuild && mv dist/tempbuild dist/nginx",...
angular.json add on
projects -> *projectname* -> architect -> build -> options:
And the result:
- on build starts, the folder
previousbuildwill be erased
- the new build will be created on
- when the new build is done, the previous production build will move to
previousbuildand the new one will be on
- in case that you need to recover the previous version, you only need rename the two folders