Last active
December 19, 2015 21:19
-
-
Save james-gardner/6019744 to your computer and use it in GitHub Desktop.
Basic attempt at a grunt file that concatenates and minifies CSS (from LESS) and JavaScript into a folder based upon the given version label.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require("path"); | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
less: { | |
options: { | |
yuicompress : true | |
}, | |
desktop : { | |
files: { | |
'<%= grunt.option(\"feature\") %>/styles/desktop/global.min.css' : 'styles/desktop/less/global.less' | |
} | |
}, | |
mobile : { | |
files: { | |
'<%= grunt.option(\"feature\") %>/styles/mobile/global.min.css' : 'styles/mobile/less/global.less' | |
} | |
} | |
}, | |
uglify : { | |
desktop: { | |
options : { | |
compress : true | |
}, | |
files: { | |
'<%= grunt.option(\"feature\") %>/scripts/desktop/common.min.js' : [ | |
'scripts/desktop/main.js', | |
'scripts/desktop/util.js', | |
'scripts/desktop/zero.js', | |
] | |
} | |
}, | |
mobile : { | |
files: { | |
'<%= grunt.option(\"feature\") %>/scripts/mobile/common.min.js' : 'scripts/mobile/main.js', | |
} | |
} | |
}, | |
watch : { | |
scripts : { | |
files : ['**/*.js'], | |
tasks : ['uglify'] | |
}, | |
styles : { | |
files : ['**/*.less'], | |
tasks : ['less'] | |
} | |
} | |
}); | |
// There's probably a better way of doing this. | |
// I needed my assets to be published to versioned folders. | |
var feature = grunt.option('feature'); | |
if(typeof feature === 'undefined') { | |
grunt.fail.fatal('Please supply a version number.'); | |
} else { | |
grunt.option('feature', path.join('../', grunt.option('feature'))); | |
} | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-less'); | |
// Register a default task. | |
grunt.registerTask('default', ['uglify', 'less']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment