-
Notifications
You must be signed in to change notification settings - Fork 12k
Unique identifier ng build --prod #3769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
These identifiers are added to prevent loading of old bundles from a cache. By removing them you risk users loading old bundles from their cache in the event you start serving a new build without different bundle names. |
Ok so I need to find a way, in my Index.cstml for example, to "guess" identifiers. Any idea? |
Well, you can be sure of most of the filename for all of them, and the identifiers are just hash strings. Sounds like time for regular expressions and/or a file map! |
Was afraid of that haha. Im quite unfamiliar with regex. Regex demon to fight! |
Is there any way we can set the names for these files so that everytime it will generate the same file and we don't have to change anything in .cshtml file |
@ersurajnegi Let me reiterate: These hashes are there to prevent a browser from accidentally loading a cached and out of date version of your application. By forcing them to all be the same name consistently across builds you have a high risk of users loading the wrong bundle and performing actions with undefined behavior. The regex to match these isn't too difficult. |
@psaussure If you don't need the hashes (and know how to deal with caches), use the following BASH command (from your project root): for src in dist/*.bundle.*; do
dest=$(echo $src | sed "s/\\.[0-9a-z]*\\.bundle/.bundle/")
mv $src $dest
done That will remove all the hashes in the Closing this as fixed (per this comment and discussion above). |
Is the hash in the filename really necessary though? I have the same problem... I'm using WiX to deploy my angular application along with a windows service and a few other things. The problem is that deployed files in WiX need to be explicitly defined in an XML document like so:
To make sure no stale javascript/css/etc are loaded, that's what I currently have in my not-angular-cli-project-yet in the webpack config:
The generated index.html would reference these files like: |
for src in dist/.bundle.; do This removes the identifiers from the bundle from the dist folder but the path also get change in index.html too .. how can we manipulate in that But it also updates the path with that identifiers in index.html file too |
you can also do that : #3885 but for a project I'm working on (and optimizing) I would need to remove hash only for the scripts/libraries lazy loaded as I'm only able to load them by adding a script element with the src attribute being "myscript.bundle.js". Unless someone knows a way to dynamically get those hash to get the right name, I'll have to remove the hash for those scripts/libraries. |
We can avoid hashing the filename during build using ng build --output-hashing. you can refer |
@gelliott181 I'm using aspnet core new angular 5 template, I'm getting multiple bundles of same name
unable to figure out which one to pick. |
Kindly check the index.html of your application. The correct file will be
specified in the src of the script tag.
On Feb 23, 2018 5:24 PM, "AlwaysAbhl001" <notifications@github.com> wrote:
The regex to match these isn't too difficult. /(main|styles|scripts|vendor|
inline).*.bundle.(map|js|css)/g will match all eight files.
@gelliott181 <https://github.com/gelliott181> I'm using aspnet core new
angular 5 template, I'm getting multiple bundles of same name
like
inline.*.bundle.js
inline.*.bundle.js
inline.*.bundle.js
unable to figure out which one to pick.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3769 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AhQ9mZcpKhAQen1Px7SpGumy4TO2rYJhks5tXqb0gaJpZM4LXGLN>
.
|
but by doing this we don't face any cache problems like getting old one ? cause we do all these in continues integration rather then separately generating prod dist files manually so having concern on caches. |
I was able to solve this by using ng build --prod --named-chunks. hope that helps someone looking for this |
ng build --prod --output-hashing=none is the right thing to do here. Refer to https://stackoverflow.com/questions/39718803/custom-generated-filename-with-angular-cli |
the hashes are useless, we keep having customers complaining about non working functionalities while CTRL+F5 solves the issue every time the only way we could fix this was to eject angluar cli project and add a build number or a date manualy to each filename...then you cant use ng command on the project anymore this just s@#ks please add a feature so we can add a custom string to the hash, or replace the hash at all, from the command line |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When compiling with
ng build
, I get standard file names:but with
ng build --prod
i get some identifiers added to file names.Are these identifiers always the same in a given app?
It it possible to change the behavior of prod build not to have these identifiers added to file name?
My own app is deeply intergrated with .NET project and my app loading is based on files without identifier. I don't want to have to edit my .NET view template in order to add at each build the unique identifier.
Side question: _prod is supposed to apply some tree-shaking, but as you can see on the logs pasted above, the vendor bundle is 4.79MB on normal build and 4.57MB on prod.
My app simply use basic routing, angularfire2 and http module. Is this size normal?
The text was updated successfully, but these errors were encountered: