Created
September 17, 2012 17:32
-
-
Save zentooo/3738650 to your computer and use it in GitHub Desktop.
grunt.js for XXX
This file contains hidden or 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
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