-
Notifications
You must be signed in to change notification settings - Fork 12k
--output-hashing doesn't work for media files of type (.png, .jpg, .gif .. etc) #4212
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
Files within your assets are not processed by the build process (just copied). As a result, their use, if any, (and location of use) cannot be determined. |
@clydin - The fonts are handled correctly and if they are hashed the references to the newly hashed font files are also updated. The code that handles the images seems to be similar to that of the font files. The only difference here is that the fonts are copied at the index.html level and the images are in the assets directory. So, would it be correct to assume that if let's say a logo.png is placed at the index.html level of the dist/ directory, then it would be found and properly hashed and the references to that file are also updated? Any reference to a document that better explains both usage & limitations of One possible approach would be to use |
Files referenced from within component templates and stylesheets are not analyzed or processed. This is why they needed to be placed within the project's |
Closing as answered by @clydin. |
Can you please suggest a workaround as to how to cache media files referenced from templates? edit:
@clydin I understand what you say, however the issue described by @un33k remains very relevant and it would be worth suggesting a workaround or addressing this issue somehow. |
Any updates on this? |
Wouldn't it be, for most Cases, enough to append a GET-Style parameter to the URL (ie. transform Appending the asset hash could be controlled with a template function which could read a hash which has been computed for this file at build-time (ie. A similar approach could be taken for .less/.css-Files. |
@MaZderMind How do you do this for images in css files? |
@un33k I'm writing from a very high perspective: I do not know which parsers and filters are actually applied onto which file type by angular and/or webpackt. But I do know that angular already supports pre-processing css-files with less if you just name them accordingly and I do know that a preprocessor similar to less could be used to implement a similar function for css (ie. What I want to point out is, that by appending a GET-Parameter instead of renaming the file, the Cache-Breaking becomes a function that can be implemented at-runtime and client-side and that can have a nice fall-forward behavior, if an url is constructed at runtime for which, at build-time, no hash-code was calculated or if a resource is accessed externally. This could be a golden path out of the dilemma explained, that traditional output-hashing will not work for dynamic content (ie templates), if the only use is to break caches - which is probably the 99% use for this feature. |
At the moment all relative paths to assets from components' sass stylesheets are hashed and moved to dist/ root dir. |
After updating to Angular 7, Cli 7 I notice all assets that are with relative URLs inside the The other assets that are used in .html (example |
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. |
Versions / Env:
angular-cli: 1.0.0-beta.26
node: 6.0.0
os: darwin x64 (macOS - El Capitan)
Repro steps.
The log given by the failure.
The content of the dist/ directory is as below: Notice that the images are not hashed
dist/
├── assets
│ ├── 404.html
│ ├── css
│ │ └── loading.css
│ ├── icon
│ │ └── favicon.ico
│ ├── img
│ │ ├── logo
│ │ │ └──logo.png
│ │ └── misc
│ │ └── search.png
│ └── robots.txt
├── fontawesome-webfont.674f50d287a8c48dc19b.eot
├── fontawesome-webfont.912ec66d7572ff821749.svg
├── fontawesome-webfont.af7ae505a9eed503f8b8.woff2
├── fontawesome-webfont.b06871f281fee6b241d6.ttf
├── fontawesome-webfont.fee66e712a8a08eef580.woff
├── index.html
├── inline.67a2fb6cd14ba4fc7671.bundle.js
├── main.fdd9bda558d52de42c5f.bundle.js
├── main.fdd9bda558d52de42c5f.bundle.js.gz
├── scripts.21eca2c64fde6754ea61.bundle.js
├── scripts.21eca2c64fde6754ea61.bundle.js.gz
├── styles.0a0cdafd30d257765ef7.bundle.css
├── styles.0a0cdafd30d257765ef7.bundle.css.gz
├── styles.918490a25cf8dcdee0aa.bundle.js.gz
├── vendor.7269c21a09875bc3c8ee.bundle.js
└── vendor.7269c21a09875bc3c8ee.bundle.js.gz
More info
Please note that search.png and logo.png are NOT hashed. Also verified that hash is NOT passed into the image url as a param. (e.g. /url/image.png?hash)
Desired behavior
Note
In this example the --output-hashing=all has been passed in explicitly even though docs indicate that all is a default value for --prod. All combinations & permutations of with/without --output-hashing was attempted without a +ve result.
The text was updated successfully, but these errors were encountered: