Bruce
Bruce

Reputation: 107

grunt watch and sass is not compiling. It just notices change

I cannot figure out why my 'grunt watch' command will not compile. It is only finding that a change has been made but then it will not actually compile it into my sass.

Here is my gruntfiles.js

module.exports = function(grunt) {

  var devPath = 'dev/';
  var distPath = 'dist/';

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    sass: {
      dev: {
        options: {
          style: 'nested'
        },
        files: [{
          expand: true,
          cwd: devPath + 'scss/',
          src: ['*.scss'],
          dest: devPath + 'css/',
          ext: '.css'
        }]
      }
    },
    watch: {
      css: {
        files: [devPath + '**/*.scss'],
        tasks: ['sass:dev']
      }
    },
    emailBuilder: {
      test: {
        files: [{
          expand: true,
          cwd: 'dev/',
          src: ['*.html'],
          dest: 'dist/',
          ext: '.html',
        }]
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-email-builder');


  grunt.registerTask('sass', ['sass']);
  grunt.registerTask('dist', ['emailBuilder']);
  grunt.registerTask('default', ['watch']);
};

And then here is what I see in terminal:

Running "watch" task Waiting...

File "dev/scss/styles.scss" changed.

Upvotes: 2

Views: 130

Answers (2)

romuleald
romuleald

Reputation: 1434

I think you need to change your sass conf

    files: [{
      expand: true,
      cwd: devPath,
      src: ['scss/**/*.scss'],
      dest: devPath + 'css/',
      ext: '.css'
    }]

Upvotes: 0

Xavier Priour
Xavier Priour

Reputation: 2121

You're having an infinite loop in your sass task, just remove the below line:

grunt.registerTask('sass', ['sass']);

Upvotes: 1

Related Questions