-
Notifications
You must be signed in to change notification settings - Fork 54
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
Updating rev'ed file reference in JS files #17
Comments
I'm looking for the exact same thing. Without it one needs to do some nasty hacks to work around it. The usemin task does not allow js files to be parsed, which makes me believe this is not something that's going to be an easy fix. Maybe a separate task would be the optimal solution. |
I've moved the reference to the file (a Web Worker) to within the index file, inside a script tag I have the code: var tweetsWorker = new Worker('/scripts/tweetsWorker.js'); Now all the other JS files are merged and minified using the syntax like:
Now, in my Gruntfile in order to copy the Worker js file(s) I added this:
But the way I have rev setup it would version the Worker.js files with a hash prefixed to the name, BUT the reference in the JS of the index file was NOT updated. My current workaround is to tell rev NOT to version *Worker.js files.... BUT considering everything else works so beautifully, I don't want to run into cache issues in this one place. BTW, here's the code to ignore the *Worker.js files (as you can probably guessed):
Anyway, I made it far enough to get all the references to version-ed code to the index.html file, but still can't figure out how to get this to work automatically, which would be amazing. |
+1 |
1 similar comment
+1 |
by adding following snippet in your Gruntfile.js, you can update the versioned worker file: // Performs rewrites based on rev and the useminPrepare configuration
usemin: {
options: {
assetsDirs: ['<%= yeoman.dist %>'],
//add pattern for worker
patterns: {
worker: [
[/new Worker\(['"]([^"']+)['"]/gm,
'Update the Workers to reference our concat/min/revved script files'
]
]
}
},
//...add a worker target
worker: ['<%= yeoman.dist %>/scripts/*.js']
}, |
+1, unkstar: you saved my day |
I'm making web workers, and using grunt (yeoman setup) to copy and uglify and version my JS. The versioning works in the HTML index because it has the build comments. But the web workers are referenced inside a JS file. Is there a way to get these URL references in my JS to update with the rev'ed paths... or can I not use rev on the web workers because of this?
The text was updated successfully, but these errors were encountered: