3

I am new to Angular. I see that, there are some files like runtime.js, polyfills.js, main.js, styles.css etc getting generated by Angular cli when creating a new project. When I build the app using ng build command, inside the dist directory, I am getting similar files with a random number added in these file names like main.some_random_number.js

Is there any configuration that will stop this file name change? I am having issues on accessing these files through Express.js path since I don't know what file name will be after I run ng build command.

enter image description here

1 Answer 1

8

Angular is cache busting the files, so that when you deploy a new version, there is no chance that, old code will be viewed in your browser.

If you want to cache bust your application, you need to toggle the flag.

--output-hashing - controls addition of the cache busting random string.

As per angular documentation.

--output-hashing Define the output filename cache-busting hashing mode.

none | all | media | bundles

So set it to none to remove the hash.

You can either set it in the command ng build --output-hashing=none or in the angular.json configurations array

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.