Skip to content

Instantly share code, notes, and snippets.

@daveroma
Last active May 21, 2016 22:51
Show Gist options
  • Save daveroma/2058e6b77ca86254282ae53fab09db0d to your computer and use it in GitHub Desktop.
Save daveroma/2058e6b77ca86254282ae53fab09db0d to your computer and use it in GitHub Desktop.
Use Grunt to pre-compile less and javascript files
module.exports = function(grunt) {
grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: [
{
expand: true, // Enable dynamic expansion.
cwd: 'less/', // Src matches are relative to this path.
src: ['**/*.less', '!{variables,mixins}*.less'],
dest: 'public/css/', // Destination path prefix.
ext: '.css' // Dest filepaths will have this extension.
}
]
}
},
uglify: {
my_target: {
files: [{
expand: true,
cwd: 'views/',
src: '**/*.js',
dest: 'public/js'
}]
}
},
watch: {
styles: {
files: ['less/**/*.less'], // which files to watch
tasks: ['newer:less'],
options: {
nospawn: true
}
},
scripts:
{
files: ['views/**/*.js'],
tasks: ['uglify'],
options: {
spawn: false,
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-newer');
grunt.registerTask('default', ['watch']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment