Skip to content

Instantly share code, notes, and snippets.

@zentooo
Created Sep 17, 2012
Embed
What would you like to do?
grunt.js for XXX
module.exports = function(grunt) {
var now = String(Date.now());
var jsResult = "<%= dirs.js %>/target/" + now + ".js";
var cssResult = "<%= dirs.css %>/target/" + now + ".css";
var jsGzipped = jsResult + ".gz";
var cssGzipped = cssResult + ".gz";
var compressFiles = {};
compressFiles[jsGzipped] = jsResult;
compressFiles[cssGzipped] = cssResult;
grunt.initConfig({
dirs: {
js: "public/javascripts",
css: "public/stylesheets"
},
watch: {
scripts: {
files: ["<%= dirs.js %>/*.js", "<%= dirs.css %>/*.css"],
tasks: 'default'
}
},
clean: ["<%= dirs.js %>/target", "<%= dirs.css %>/target"],
concat: {
js: {
src: ["<%= dirs.js %>/jquery-1.8.1.js", "<%= dirs.js %>/bootstrap.js"],
dest: "<%= dirs.js %>/target/all.js"
},
css: {
src: [
"<%= dirs.css %>/bootstrap.css",
"<%= dirs.css %>/bootstrap-responsive.css",
"<%= dirs.css %>/main.css",
"<%= dirs.css %>/plus.css"
],
dest: "<%= dirs.css %>/target/all.css"
}
},
min: {
js: {
src: ["<%= dirs.js %>/target/all.js"],
dest: jsResult
}
},
cssmin: {
css: {
src: ["<%= dirs.css %>/target/all.css"],
dest: cssResult
}
},
compress: {
gzip: {
options: {
mode: "gzip"
},
files: compressFiles
}
},
replace: {
tmpl: {
src: ["views-src/main.scala.html"],
dest: "app/views",
variables: {
timestamp: now
}
},
conf: {
src: ["conf-src/application.conf"],
dest: "conf",
variables: {
timestamp: now
}
}
}
});
grunt.loadNpmTasks('grunt-contrib');
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-replace');
grunt.registerTask('default', 'clean concat min cssmin compress replace');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment