Skip to content

Instantly share code, notes, and snippets.

@guillaumepiot
Last active December 16, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillaumepiot/5363386 to your computer and use it in GitHub Desktop.
Save guillaumepiot/5363386 to your computer and use it in GitHub Desktop.
Grunt default config file
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
main: {
files: [
{expand: true, cwd: 'components/bootstrap/', src: ['less/*.less', 'img/*'], dest: 'src/', filter: 'isFile'}, // includes files in path
{expand: true, cwd: 'components/bootstrap/js/', src: ['*.js'], dest: 'src/js/bootstrap/', filter: 'isFile'}, // includes files in path
{expand: true, cwd: 'components/jquery/', src: ['jquery.js'], dest: 'src/js/', filter: 'isFile'}
//{src: ['path/**'], dest: 'dest/'}, // includes files in path and its subdirs
//{expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'}, // makes all src relative to cwd
//{expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'} // flattens results to a single level
]
}
},
concat: {
options: {
// define a string to put between each file in the concatenated output
separator: ';'
},
dist: {
// bootstrap{
// // the files to concatenate
// src: ['src/js/bootstrap/*.js'],
// // the location of the resulting JS file
// dest: 'build/js/bootstrap.js'
// },
// jquery{
// // the files to concatenate
// src: ['src/js/jquery.js'],
// // the location of the resulting JS file
// dest: 'build/js/jquery.js'
// }
files: {
'build/js/ck/bootstrap.js': ['src/js/bootstrap/*.js'],
'build/js/ck/jquery.js': ['src/js/jquery.js']
}
}
},
uglify: {
options: {
// the banner is inserted at the top of the output
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'build/js/min/bootstrap.min.js': ['build/js/ck/bootstrap.js'],
'build/js/min/jquery.min.js': ['build/js/ck/jquery.js']
}
}
},
jshint: {
// define the files to lint
files: ['gruntfile.js'],
// configure JSHint (documented at http://www.jshint.com/docs/)
options: {
// more options here if you want to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint', 'concat', 'uglify']
}
});
// Load libs
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
// Register the default tasks
grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
// Register building task
grunt.registerTask('build', ['copy']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment