sails.js Asset Versioning
node.js, sails.js
Solution
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.
Problem
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?