In #3401 the functionality to add new style bundles and set them to lazy load making them not automatically included in the app was added, and it works great! However it is currently impossible to predict the hash of the files, forcing you to disable output-hashing if you want to be able to load it yourself into the application.
It would be great to have a function of sorts where we could fetch the file name of the bundle by supplying the bundle name.
angular-cli.json example:
"prefix": "app",
"styles": [
{ "input": "scss/red.scss", "output": "red", "lazy": true },
{ "input": "scss/blue.scss", "output": "blue", "lazy": true },
{ "input": "scss/green.scss", "output": "green", "lazy": true },
{ "input": "scss/yellow.scss", "output": "yellow", "lazy": true }
],
It would be great to have something in the way of:
const filename = this.cli.getStyleBundleByName('red);
Or something similar.
Another solution could be to add a flag to generate a assets.json file that only contains the asset file names. I tried doing this with the --stats-json file but it is more than 17mb big making it not such a good solution.
@Epenance I wouldn't limit this to style bundles but script bundles as well.
@deebloo I agree.
The script bundles currently don't have the hash, but the styles do unfortunately. This is a bug but we haven't found a good way to fix it.
@filipesilva I see, I personally dont think the hash itself is a bad thing, as long as there is a way to know it, its good for invalidating caches :)
I also discovered this need while trying to implementing lazy loaded themes like https://material.angular.io/
meanwhile an implementation of when "hash": false set, prevent from generating hash would be helpful.
"prefix": "app",
"styles": [
{ "input": "scss/red.scss", "output": "red", "lazy": true , "hash": false},
{ "input": "scss/blue.scss", "output": "blue", "lazy": true , "hash": false},
{ "input": "scss/green.scss", "output": "green", "lazy": true , "hash": false},
{ "input": "scss/yellow.scss", "output": "yellow", "lazy": true , "hash": false}
],
we need hashing for rest of the files for cache busting.
a potential temp solution is enabling service-workers and finding hash from ngsw.json
Encountered the same problem when trying to lazy load assets manually too, without sacrificing bundle hashes.
Even just having a manifest/assets json file, output within /dist, that just included "assetsByChunkName" from stats.json would go a long way.
We've since remove hashes from the lazy bundles so I think this is solved.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Encountered the same problem when trying to lazy load assets manually too, without sacrificing bundle hashes.
Even just having a manifest/assets json file, output within /dist, that just included "assetsByChunkName" from stats.json would go a long way.