The Grunt.js project is able to execute tasked commands such as minification and concatenation as I described above. The two grunt.js plugins with the widest support for these tasks are:
- Uglify (minification)
- Concat (file concatenation)
below is a sample task script for these:
module.exports = function(grunt) {
grunt.initConfig({
concat: {
options: {
separator: ';'
},
dist: {
src: ['assets/**/*.js'],
dest: 'assets/js/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'assets/js/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['concat', 'uglify']);
};
I dont usually answer my onw questions although i believe that relying on a server to compile, cache and check cached versions is not the way to go. Unnecessary processors and systems to maintain on a production environment.