Skip to content

Instantly share code, notes, and snippets.

@e-river

e-river/Gruntfile.js

Created Jan 15, 2014
Embed
What would you like to do?
Gruntfile.js using grunt-contrib-cssmin, grunt-contrib-watch, grunt-contrib-concat, grunt-contrib-clean, grunt-contrib-compass, grunt-contrib-uglify
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
//Concatenate JS files
concat: {
lib: {
src: [
'public_html/dev/lib/jquery.js',
'public_html/dev/lib/jquery_easing_min.js'
],
dest: 'public_html/js/lib/lib.js'
},
dev: {
src: [
'public_html/dev/script.js',
'public_html/dev/hoge.js'
],
dest: 'public_html/js/app.js'
}
},
//compass
compass: {
dist: {
options: {
config: 'config.rb',
sassDir: 'sass',
cssDir: 'css',
imagesDir: 'img'
}
},
dev: {
options: {
config: 'config.rb',
sassDir: 'dir/sass',
cssDir: 'dir/css',
imagesDir: 'dir/img'
}
}
},
//Minify CSS files
cssmin: {
combine: {
files: {
'public_html/css/style.css': ['public_html/css/style.css']
}
}
},
//Minify JS files with UglifyJS
uglify: {
lib: {
src: 'public_html/js/lib/lib.js',
dest: 'public_html/js/lib/lib.min.js'
},
dev: {
src: 'public_html/js/app.js',
dest: 'public_html/js/app.min.js'
}
},
//Clear files
clean: [
'public_html/js/lib/lib.js',
'public_html/js/app.js'
],
//Watcing files change
watch: {
js: {
files: [
'public_html/dev/**/*.js'
],
tasks: ['concat', 'uglify']
},
scss: {
files: [
'public_html/sass/*.scss'
],
tasks: 'compass:dist'
},
scss2: {
files: [
'public_html/dir/sass/*.scss'
],
tasks: 'compass:dev'
}
}
});
var taskName;
for(taskName in pkg.devDependencies) {
if(taskName.substring(0, 6) == 'grunt-') {
grunt.loadNpmTasks(taskName);
}
}
//deploy task, enter 'grunt deploy'
grunt.registerTask('deploy', ['clean', 'cssmin']);
//default task, enter 'grunt'
grunt.registerTask('default', ['watch', 'concat', 'compass', 'uglify']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.