Skip to content

Instantly share code, notes, and snippets.

@boycott
Created February 20, 2014 09:52
Show Gist options
  • Save boycott/9110236 to your computer and use it in GitHub Desktop.
Save boycott/9110236 to your computer and use it in GitHub Desktop.
Example (working?) grunt watch task
var settings = require('./settings');
module.exports = function(grunt) {
grunt.initConfig({
settings: grunt.file.readJSON('settings.json'),
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
banner: '(function () {\n\'use strict\';\n',
footer: '}());'
},
dist: {
src: ['source/application.js', 'source/modules.js', 'source/dimensions.js', 'source/nav-arrows.js', 'source/ready.js', 'source/content.js'],
dest: '<%= settings.target %><%= pkg.name %>.js'
}
},
less: {
development: {
files: {
"<%= settings.target %><%= pkg.name %>.css": "source/<%= pkg.name %>.less"
}
},
production: {
options: {
cleancss: true
},
files: {
"<%= settings.target %><%= pkg.name %>.min.css": "source/<%= pkg.name %>.less"
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.description %> v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %>*/\n'
},
build: {
src: '<%= settings.target %><%= pkg.name %>.js',
dest: '<%= settings.target %><%= pkg.name %>.min.js'
}
},
watch: {
options: {
spawn : false
},
css: {
files: 'source/<%= pkg.name %>.less',
tasks: 'less'
},
scripts: {
files: 'source/*.js',
tasks: ['concat', 'uglify']
}
},
newer: {
options: {
cache: 'cache'
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-newer');
grunt.registerTask('default', ['newer:less', 'newer:concat', 'newer:uglify']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment