Grunt浏览器同步仅适用一次

时间:2016-02-19 16:05:31

标签: gruntjs browser-sync

我写了一个grunt文件,它也使用了BrowserSync。 我设法让它工作,但由于某种原因它只能工作一次。

如果我对我的sass文件进行了更改,它会编译并重新加载浏览器。 但是,如果我再次更改sass文件,它会编译但不再重新加载。

module.exports = function(grunt) {

require('load-grunt-tasks')(grunt);
var compass = require('compass-importer');

grunt.initConfig({
    watch: {
      sass: {
        files: ['sass/**/*.scss'],
        tasks: ['sass']
      }
    },
    sass: {
        options: {
             importer: compass,
             sassDir: 'sass',
             cssDir: 'css',
             imagesPath: 'img',
             noLineComments: true,
             outputStyle: 'nested',
             sourceMap: true,
             debugInfo: true
        },
        dev: {
            files: {
                // destination    // source file
                'css/theme.css': 'sass/theme.scss'
            }
        }
    },
    browserSync: {
      default_options: {
        bsFiles: {
          src: [
            "css/*.css",
            "*.html",
            "*.php"
          ]
        },
        options: {
          watchTask: true,
          proxy: "192.168.22.44/"
        }
      }
    }
});

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

// register a default task.
grunt.registerTask('default', ['browserSync', 'watch']);

};

由于

0 个答案:

没有答案
相关问题