【问题标题】:grunt watch and sass is not compiling. It just notices changegrunt watch 和 sass 没有编译。它只是注意到变化
【发布时间】:2015-06-03 23:57:56
【问题描述】:

我无法弄清楚为什么我的“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”已更改。

【问题讨论】:

  • 如果你测试grunt sass:dev会发生什么?
  • 如果您在子文件夹中有.sass 文件,它们将不会继续(除非您@importing 它们)。

标签: javascript sass gruntjs


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    我认为您需要更改您的sass conf

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-01
      • 2014-03-14
      • 2023-03-12
      • 2015-02-14
      • 2013-09-24
      • 1970-01-01
      • 2017-03-16
      • 1970-01-01
      相关资源
      最近更新 更多