-
Notifications
You must be signed in to change notification settings - Fork 339
blockReplacements run before filerev linking #444
Comments
In other words: we want to manipulate the final imported assets uris, and not the ones generated before filerev. This way we can support our application at other contexts than root, for example. |
For anyone else that is having this issue, here's a workaround. Specify your blockReplacement however you like (in this case, we had to prepend a JSP context root onto the outputted path):
Then, create a custom task that also replaces the filerev map with the prefixed data. Note that you need to stick the prefix after the root path on the filesystem. In our case, it was
Finally, insert this task between filerev and usemin in your build task:
Really hokey, and it took me a long time to figure out. Hopefully this issue gets fixed so you can just use the |
@monitorjbl @leocwolter regarding the If this is the case, I think you should rewrite all you revved assets after the usemin process is complete using any grunt plugin like Waiting for your answer. |
The goal was to append the Does your suggestion still apply? I'm not that familiar with other Grunt plugins. |
@monitorjbl there are plugins like grunt-cdn or grunt-cdnify. |
@monitorjbl I do not want to say that's a better to use another plugin. Your solution to create your own grunt task is good too. |
CC @sindresorhus what do you think about it ? |
I encountered this issue as well while trying to use usemin with filerev in a Django project. I could use something like Basically, I want my grunt workflow to be agnostic about where the files will eventually end up being hosted. Though, my use case might just be too specific. That is, trying to use usemin for Django templates. |
Ahh I just found this after posting a similar issue. I've attempted to use |
After I spent 1.5 days fixing this problem, I thought I share my solution for the simplest usecase: I wanted to prepend the revved url paths with the cdn base url/the app's base url (for the local devenv).
(Note I'm serving my templates with Flask, so Luckily there's a PR waiting for reviewers: #613 |
When using filerev before usemin, the output given to a
blockReplacements
function is the original filename instead of the filerev-adjusted file name (suffixed with a hash). To properly use this option, theblockReplacements
functions should be called after the filrev-linking has been done and the hashed filenames are available.The text was updated successfully, but these errors were encountered: