Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

Angular Universal and Firebase Hosting - What is this long string between main and .js?

In the Angular Universal project, sometimes when I run 'ng deploy', main.xxxxxxxx.js file is generated instead of main.js in /dist/my-project/dist/my-project/server directory. Does anyone know what's the difference between main.xxxxxxxx.js and main.js? Also In what circumstances does main.xxxxxxxx.js is created instead of main.js when 'ng deploy' is run? Thanks.

Image for main.xxxxxxxx.js

Image for main.js


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Angular generates unique file names when you build your application. Angular does this by adding the file checksum (hash) to the filename.

Why? Browsers and proxies can cache files. When you build a new version of your application you want users to get the new files, not the old ones from a cache. Because Angular generates unique file names, these files are not in any cache and users get the new version.

However, Angular only does this depending on the configuration (outputHashing configuration option). I am guessing that you get the files with the hash on a production build (ng build --prod) and the plain file names on a development build (ng build).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...