I'm new to Grunt. I thought I'd give it a try, so I created this grunt file.
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
css: {
src: [
'./css/*'
],
dest: './css/all.css'
},
js: {
src: [
'./js/*'
],
dest: './js/all.js'
}
},
uglify: {
js: {
files: {
'./js/build/all.min.js': ['./js/all.js']
}
}
},
sass: {
build: {
files: [{
expand: true,
cwd: './css/sass',
src: ['*.scss'],
dest: './css',
ext: '.css'
}]
}
},
cssmin: {
css: {
src: './css/all.css',
dest: './css/build/all.min.css'
}
},
watch: {
files: ['./css/sass/*', './js/*'],
tasks: ['sass:build','concat:css', 'cssmin:css', 'concat:js', 'uglify:js']
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('dev', ['sass:build','concat:css', 'cssmin:css', 'concat:js', 'uglify:js']);
};
When I run 'grunt watch' and make a change to an .scss file, terminal complains and then aborts.
Running "watch" task
Waiting...
>> File "css/sass/all.scss" changed.
Running "sass:build" (sass) task
File css/all.css created.
Running "concat:css" (concat) task
Warning: Unable to read "./css/build" file (Error code: EISDIR). Use --force to continue.
Aborted due to warnings.
Completed in 1.276s at Thu May 01 2014 23:53:59 GMT+0100 (BST) - Waiting...
Please can someone point out where I'm going wrong?
It looks to be with the concat:css
- but there's no reference to the build directory there.
I believe it may be because certain tasks are colliding and files aren't ready yet to be worked with perhaps? Is there an order to tasks?
Please bear with me as it's all new!
Thanks, Michael.