I'm using the sails.js asset linker.
I'm versioning my assets by appending an asset version in it like so:
assetfile.js?=<%= assetVersion %>
Unfortunately, this doesn't work because the js file names are being replaced by the linker!
Does the sails.js linker support a work around for this? Or am I left on my own to hack the grunt file?
If you are hosting from a git repository, you can use the git commit sha to identify version.
I use this approach in one of my projects, and it consists of adding the following as rename.js
to tasks/config
var git = require('git-rev')
module.exports = function(grunt) {
git.short(function(hash) {
var files = {
'.tmp/public/min/production.' + hash + '.min.js': '.tmp/public/min/production.min.js',
'.tmp/public/min/production.' + hash + '.min.css': '.tmp/public/min/production.min.css'
}
grunt.config.set('rename', {
dist: {
files: files
}
})
})
grunt.loadNpmTasks('grunt-rename')
};
and then adding the rename task in tasks/register/prod.js
just before the linker tasks.
Based on @CaseyWebb's solution we extended our sails app to address versioning issue with timestamp. There's also a very detailed blog entry about this here: https://naya.com.np/post/391862c0520b5b5632e99e812749a85b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With