【问题标题】:Grunt BrowserSync and SASS watchGrunt BrowserSync 和 SASS 手表
【发布时间】:2015-02-19 16:48:10
【问题描述】:

我在使用 SASS 处理的监视任务设置 BrowserSync 时遇到一些问题。

当我执行时:

grunt

BrowserSync 服务器启动,我看到“Serving files from: ./ and Watching files。sass 从未编译过。就像两个任务都没有启动一样。

当我执行时:

grunt watch

sass 被监视并正确编译,但没有启动 BrowserSync 服务器。

module.exports = function(grunt) {

grunt.initConfig({
    watch: {
        files: 'components/css/scss/*.scss',
        tasks: ['sass']
    },

    sass: {                              // Task
        dist: {                            // Target
          options: {                       // Target options
            style: 'expanded'
          },
          files: {                         // Dictionary of files
            'components/css/screen.css' : 'components/css/scss/screen.scss'        // 'destination': 'source'
          }
        }
    },

    browserSync: {
        bsFiles: {
            src : ['components/css/*.css', '*.html']
        },
        options: {
            server: {
                baseDir: "./"
            },
            options: {
                watchTask: true
            }
        }
    }
});

grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browser-sync');

grunt.registerTask('default', ["browserSync", "watch"]);

};

【问题讨论】:

    标签: sass gruntjs browser-sync


    【解决方案1】:

    这可能会修复错误:

        browserSync: {
            bsFiles: {
                src : ['components/css/*.css', '*.html']
            },
            options: {
                server: {
                    baseDir: "./"
                },
                watchTask: true
            }
        }
    

    watchTask 选项出错。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-15
      • 2020-06-04
      • 2014-08-07
      • 1970-01-01
      • 2015-05-13
      • 1970-01-01
      • 2015-02-14
      相关资源
      最近更新 更多