-
Notifications
You must be signed in to change notification settings - Fork 32
Conversation
@borodean problem is that query bases cachbaster like It will be better for cachebuster: function (path) {
return path.basename(path, path.extname(path)) + '-' + hash(path) + path.extname(path);
} |
@borodean any updates? This is not only Rails issue. For example, many Gulp pluugins adds hash to the file name. |
Any updates here? For example, we now has separated plugin for cache buster in dir: https://github.com/code42day/postcss-cachify But if we had optin that we ask, this plugin will be unnecessary. |
@ai use postcss-url, it fits quite well for that. |
I’m trying to get this working using a syntax similar to the one which Compass uses. Here is how it could look likeTo define a custom cachebuster pass a function as an option: var options = {
cachebuster: function (filePath) {
return fs.statSync(filePath).mtime.getTime().toString(16);
}
}; If the returned value is falsy, no cache busting is done for the asset. If the returned value is an object the values of If the returned value is a string, it is added as a query string. The returned values for query strings must not include the starting Busting the cache via path: var options = {
cachebuster: function (filePath, urlPathname) {
var hash = fs.statSync(filePath).mtime.getTime().toString(16);
return {
pathname: path.dirname(urlPathname) + '/' + path.basename(urlPathname, path.extname(urlPathname)) + hash + path.extname(urlPathname),
query: false // you may omit this one
}
}
}; |
Conflicts: test/assets.js
@borodean yeap, object API is nice way to save current behaviour. Do you need any help? |
👍 |
Hi, I'm using postcss-assets with Rails-style cachebuster:
application-7a0306d552d84deaa57f0af77c99a8ed.js
. As you can see It's not query string based. It would be nice to change thecachebuster
callback in order to support this. Or pass in an argument with assets paths:{'application': application-7a0306d552d84deaa57f0af77c99a8ed.js}
.