Skip to content

Instantly share code, notes, and snippets.

@abdulapopoola
Last active Dec 17, 2015
Embed
What would you like to do?
Sample GruntJS config file
module.exports = function(grunt) {
grunt.initConfig({
qunit: {
files: ['test/**/*.html']
},
jshint: { //Lint files, different tasks exist
tests: { //lint JS tests
files: {
src: ['test/**/*.js']
},
options: {
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
target: { //lint production JS
files: {
src: ['target/controllers/*.js',
'target/models/*.js',
'target/routes/*.js',
'target/views/*.js',
'target/app.js',
'target/main.js']
},
options: {
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
}
},
watch: { //Watch files for changes
scripts: {
options: {
livereload: true
},
files: ['./js/**/*'],
tasks: ['jshint']
}
},
compass: { //Compile SASS into CSS
dist: {
options: {
config: './public/config.rb',
sassDir: './public/css/scss/',
cssDir: './public/dump',
imagesDir: './public/images',
outputStyle: 'compressed',
noLineComments: true
}
},
dev: {
options: {
config: './public/config.rb',
sassDir: './public/css/scss/',
cssDir: './public/css'
}
}
},
cssmin: { //minify CSS
minify: {
files: {
'./public/css/prd.min.css': ['./public/css/styles.css']
},
options: {
report: 'gzip'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('test', ['jshint:js', 'qunit']);
grunt.registerTask('prod', ['jshint:js', 'compass:dist', 'cssmin']);
grunt.registerTask('default', ['jshint:js', 'compass:dev', 'compass:dist']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment