Skip to content

Instantly share code, notes, and snippets.

@luissquall
Last active December 16, 2015 08:48
Show Gist options
  • Select an option

  • Save luissquall/5408257 to your computer and use it in GitHub Desktop.

Select an option

Save luissquall/5408257 to your computer and use it in GitHub Desktop.
Apply tasks only to changed files.
/*global module:false*/
module.exports = function(grunt) {
// Load tasks
grunt.loadTasks('util/grunt');
// Load vendors tasks
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
// Project configuration
grunt.initConfig({
compass: {
dist: {
options: {
config: 'config.rb'
}
}
},
uglify: {
dist: {
expand: true,
cwd: 'app/webroot/js/src/',
src: ['**/*.js'],
dest: 'app/webroot/js/build/'
}
},
jshint: {
dist: {
src: ['app/webroot/js/src/**/*.js']
}
},
watch: {
options: {
nospawn: true
},
stylesheets: {
files: 'app/webroot/css/src/**/*.scss',
tasks: ['compass']
},
scripts: {
files: 'app/webroot/js/src/**/*.js',
tasks: ['jshint', 'uglify']
}
}
});
grunt.event.on('watch', function(action, filepath) {
if (grunt.file.isMatch(grunt.config('watch.stylesheets.files'), filepath)) {
grunt.config('compass.dist.options.specify', [filepath]);
}
if (grunt.file.isMatch(grunt.config('watch.scripts.files'), filepath)) {
var uglifySrc = filepath.replace(grunt.config('uglify.dist.cwd'), '');
grunt.config('jshint.dist.src', [filepath]);
grunt.config('uglify.dist.src', [uglifySrc]);
}
});
// Default task.
grunt.registerTask('default', ['compass', 'jshint', 'uglify']);
};
@jonakyd
Copy link
Copy Markdown

jonakyd commented Oct 28, 2013

doesn't work either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment