Skip to content

Instantly share code, notes, and snippets.

@huanglong-zz
Last active December 31, 2015 05:39
Show Gist options
  • Save huanglong-zz/7942052 to your computer and use it in GitHub Desktop.
Save huanglong-zz/7942052 to your computer and use it in GitHub Desktop.
module.exports = function(grunt) {
// Project Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
development: {
options: {
paths: ['public/assets/modules'],
compress: true,
yuicompress: true,
optimization: 2,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
'public/assets/css/xx/about.css': 'public/assets/less/about.less',
'public/assets/css/xx/launch.css': [
'public/assets/modules/bootstrap.less',
'public/assets/modules/bootstrap-responsive.less',
'public/assets/less/index.less'
]
}
}
},
cssmin: {
add_banner: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
'public/assets/build/<%= pkg.version %>/<%= pkg.name %>.min.css': [
'public/lib/bootstrap/docs/assets/css/bootstrap.css',
'public/lib/bootstrap/docs/assets/css/bootstrap-responsive.css',
'public/assets/css/beta/about.css'
]
}
}
},
uglify: {
development: {
options: {
mangle: false,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
'public/assets/build/<%= pkg.version %>/<%= pkg.name %>.min.js': [
'public/lib/toastr/toastr.js',
'public/utils/datepicker/js/bootstrap-datepicker.js',
'public/js/app.js',
'public/js/init.js'
]
}
}
},
jade: {
compile: {
options: {
data: {
debug: false
}
},
files: {
'public/views/includes/index.html': ['app/views/includes/header.jade', 'app/views/includes/footer.jade'],
'public/views/includes/header.html': ['app/views/includes/header.jade']
}
}
},
watch: {
jade: {
files: ['app/views/**'],
options: {
livereload: true
}
},
js: {
files: ['public/js/**', 'app/**/*.js'],
tasks: ['jshint'],
options: {
livereload: true
}
},
uglify: {
files: ['public/js/**', 'app/**/*.js'],
tasks: ['jshint'],
options: {
livereload: true
}
},
html: {
files: ['public/views/**'],
options: {
livereload: true
}
},
css: {
files: ['public/css/**'],
options: {
livereload: true
}
},
styles: {
files: ['public/assets/**/*.less'],
tasks: ['less'],
options: {
nospawn: true
}
}
},
jshint: {
options: {
jshintrc: '.jshintrc',
ignores: ['gruntfile.js']
},
all: ['public/js/**/*.js', 'test/**/*.js', 'app/**/*.js']
},
nodemon: {
dev: {
options: {
file: 'app.js',
args: [],
ignoredFiles: ['README.md', 'node_modules/**', '.DS_Store'],
watchedExtensions: ['js'],
watchedFolders: ['app', 'config'],
debug: true,
delayTime: 1,
env: {
PORT: 4000
},
cwd: __dirname
}
}
},
concurrent: {
tasks: ['nodemon', 'watch', 'less', 'jade', 'uglify','cssmin'],
options: {
logConcurrentOutput: true
}
},
mochaTest: {
options: {
reporter: 'spec'
},
src: ['test/**/*.js']
},
bower: {
install: {
options: {
targetDir: './public/lib',
layout: 'byComponent',
install: true,
verbose: true,
cleanBowerDir: true
}
}
}
});
//Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
//Making grunt default to force in order not to break the project.
grunt.option('force', true);
//Default task(s).
grunt.registerTask('default', ['jshint', 'concurrent']);
//Test task.
grunt.registerTask('test', ['mochaTest']);
//Bower task.
grunt.registerTask('install', ['bower']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment