sindresorhus / grunt-sass

Compile Sass to CSS
MIT License
1.01k stars 209 forks source link

Since v3 grunt-contrib-watch fails to recover after grunt-sass recovers from an error #287

Closed Hlsgs closed 6 years ago

Hlsgs commented 6 years ago

3.0.1 seems correctly pass sass errors to grunt indeed, but then, after amending the error, grunt-contrib-watch only logs the file change and stops working.

Suriv commented 6 years ago

Can you show your gruntfile settings?

Hlsgs commented 6 years ago

Of course.

Here's my Gruntfile.js: ``` module.exports = function(grunt) { require('jit-grunt')(grunt, { cmq: 'grunt-combine-media-queries' }); require('time-grunt')(grunt); grunt.initConfig({ baseStyles: 'library/scss', baseCss: 'library/css', baseJs: 'library/js', baseImg: 'library/images', baseFonts: 'library/fonts', acum: grunt.template.today("dd.mm.yyyy-H.MM"), migrate: grunt.file.readJSON('migrate.json'), pkg: grunt.file.readJSON('package.json'), watch: { options: { spawn: false, interrupt: false }, sass: { files: ['<%= baseStyles %>/**/*.{scss,sass,css}', 'Gruntfile.js'], tasks: ['sass:dev' , 'postcss:dev' ] }, js: { files: ['<%= baseJs %>/**/*.js', '!<%= baseJs %>/main.js', 'Gruntfile.js'], tasks: ['concat'] }, livereload: { files: ['<%= baseCss %>/style.css', '<%= baseJs %>/main.js', '**/*.php'], options: { livereload: true , spawn: true } } }, sass: { options: { imagePath: '../images', implementation: require('node-sass') }, dev: { files: { '<%= baseCss %>/style.css': '<%= baseStyles %>/style.scss' }, options: { sourceMap: true, outputStyle: 'expanded' } } }, postcss: { dev: { options: { map: true, processors: [ require('autoprefixer')({ browsers: ['last 2 versions', 'ie > 7', 'android 2.3', 'android 4', 'opera 12', 'Firefox > 10'] }) ] }, src: '<%= baseCss %>/*.css' } }, concat: { dev: { options: { sourceMap: true }, files: { '<%= baseJs %>/main.js': [ '<%= baseJs %>/scripts.js' ] } } }, concurrent: { dev: [ 'watch:livereload', 'watch:sass', 'watch:js' ] options: { logConcurrentOutput: true } } }); grunt.registerTask('default', ['dev']); grunt.registerTask('dev', [ 'sass:dev', 'postcss:dev', 'concat', 'concurrent:dev' ]); }; ```


I've trimmed out all the unrelated stuff. Also, I've checked with and without grunt-concurrent and it's unrelated.

Suriv commented 6 years ago

Look at the grungfile of the project, this is the key.

https://github.com/sindresorhus/grunt-sass/blob/master/gruntfile.js

The new version needs Node 8 or higher

Hlsgs commented 6 years ago

@Suriv I am using the latest v10.6.0

Suriv commented 6 years ago

In the original gruntfile, he adds this:

'use strict';
const sass = require('node-sass');

module.exports = grunt => {

and

implementation: require('node-sass') by implementation: sass

It really is the same as what you have done

Also a change is that it changes dev by compile and the sourceMap option takes it out of dev, see if it looks like it works

Hlsgs commented 6 years ago

All that can't have anything to do with it. I'm not sure what to take away from what you've said.

bengosney commented 6 years ago

The issue is that done is not called when there is an error, meaning grunt-watch still thinks the task is running and wont run another one. This (https://github.com/sindresorhus/grunt-sass/pull/292) pull request solves the issue.