It seems like my watch task in my project grunt file is starting up then quitting straight away.
Please review the screenshot attached.
Please find the code for my Gruntfile.js;
module.exports = function (grunt) {
grunt.initConfig({
sass: {
options: {
cacheLocation: '.sass-cache'
},
prod: {
options: {
style: 'compressed'
},
files: [{
'assets/css/dist/main.min.css': 'assets/css/sass/main.scss'
}]
},
dev: {
options: {
style: 'nested'
},
files: [{
'assets/css/main.css': 'assets/css/sass/main.scss'
}]
}
},
imageoptim: {
files: [
'img/flat',
'img/flat/**'
],
options: {
imageAlpha: true,
jpegMini: true,
quitAfter: true
}
},
uglify: {
options: {
mangle: true,
compress: true
},
jsCompress: {
files: {
'js/dist/main.min.js': ['js/src/script1.js', 'js/src/script2.js']
}
}
},
concat: {
options: {
separator: ';',
},
dist: {
src: ['js/src/script1.js', 'js/src/script2.js'],
dest: 'js/dist/main.min.js',
}
},
watch: {
sassWatch: {
files: 'css/sass/**/*.scss',
tasks: ['sass:prod', 'sass:dev'],
},
JsWatch: {
files: ['js/modules/script1.js', 'js/modules/script2.js'],
tasks: ['uglify:jsCompress', 'concat:dist'],
}
},
notify: {
sassNotify: {
options: {
title: "Task Complete",
message: "Your Sass has been compiled and concatanatated!"
}
},
jsNotify: {
options: {
title: "Task Complete",
message: "Your JS has been minified and concatanatated!"
}
},
imageNotify: {
options: {
title: "Task Complete",
message: "All images have been compressed"
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-imageoptim');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-notify');
grunt.registerTask('sassNotify', 'watch:sassWatch');
grunt.registerTask('jsNotify', 'watch:jsWatch');
grunt.registerTask('imageNotify', 'imageoptim');
};
Does anyone have an idea why this is happening?
Kind Regards,
B!
My problem was that it was watching to much i had 100+ image files that it was keeping track of so i just specified what it should watch (js, html, scss, css).
I ran into the issue and was looking for an answer. In my case I had a typo in my files:
matching pattern which caused it to not find the directory to watch and abort, although an error message would have been nice. I notice that in your sass
task you prepend your files withassets/
but not in your watch task.
I understand you've likely moved on but hopefully this helps someone in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With