Javascript gruntjs没有';不能在sass上正常运行

Javascript gruntjs没有';不能在sass上正常运行,javascript,css,sass,gruntjs,Javascript,Css,Sass,Gruntjs,已经调试了几个小时了 当我保存我的.html文件时,livereload起作用了,但对于我的.scs文件,我在下面的配置中做了什么错误?Chrome的终端和控制台没有显示错误 module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), watch: { sass: { f

已经调试了几个小时了

当我保存我的.html文件时,livereload起作用了,但对于我的.scs文件,我在下面的配置中做了什么错误?Chrome的终端和控制台没有显示错误

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        watch: {
            sass: {
                files: ['components/sass/*.{scss,sass}'],
                tasks: ['sass']
            },
            livereload: {
                files: ['*.html', '*.php', 'js/**/*.{js,json}', 'css/*.css','img/**/*.{png,jpg,jpeg,gif,webp,svg}'],
                options: {
                    livereload: true
                }
            }
        },
        sass: {
            options: {
                sourceMap: true,
                outputStyle: 'compressed'
            },
            files: {
                'css/styles.css': 'components/sass/styles.scss'
            }
        }
    });
    grunt.registerTask('default', ['sass', 'watch']);
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
}

options.livereload
添加到您的
watch.sass
中:

watch: {
        sass: {
            files: ['components/sass/*.{scss,sass}'],
            tasks: ['sass'],
            options: {
                livereload: true
            }
        },
// ...
我也遇到过同样的问题,我相信(虽然不是100%确定)这是因为手表没有触发两个任务,如果它们在时间上太近:

  • 你修改你的sass,这会触发手表
  • 您的sass创建css
  • css创建应该触发watch,但不会触发watch,因为它是在1中触发的。几毫秒前
  • 我回答的第一行:)这样手表只会触发一次,但它会创建css并开始重新加载