grunt watch和sass没有编译。它只是注意到变化

时间:2015-06-03 14:49:00

标签: javascript sass gruntjs

我无法弄清楚为什么我的'grunt watch'命令无法编译。它只是发现已经进行了更改,但实际上它并没有将其编译成我的sass。

这是我的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']);
};

然后这就是我在终端中看到的内容:

运行“观察”任务 等待...

  
    

文件“dev / scss / styles.scss”已更改。

  

2 个答案:

答案 0 :(得分:1)

你的sass任务中有一个无限循环,只需删除以下行:

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

答案 1 :(得分:0)

我认为您需要更改sass conf

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