gulp-refresh插件不管用
发布于 8 年前 作者 QuoniamYIF 3069 次浏览 来自 问答

gulp代码如下:

var gulp = require('gulp');
var rename = require('gulp-rename');
var minifyCss = require('gulp-clean-css');
var refresh = require('gulp-refresh');

gulp.task('responsiveImg', function(){

});

gulp.task('styles', function(){
    gulp.src('css/*.css')
            .pipe(minifyCss())
            .pipe(rename({
                suffix:'-min'
            }))
            .pipe(gulp.dest('./build/css/'))
            .pipe(refresh());
});

gulp.task('watch', function(){
    // gulp.watch('js/*.js',['scripts']);
    refresh.listen()
    gulp.watch('css/*.css',['styles']);
    gulp.watch('./index.html', function(event) {
            refresh.changed(event.path);
    });
});

gulp.task('default', ['watch']);

更改文件后终端显示

[14:11:40] Using gulpfile ~/portfolioSite/gulpfile.js
[14:11:40] Starting 'watch'...
[14:11:41] Finished 'watch' after 756 ms
[14:11:41] Starting 'default'...
[14:11:41] Finished 'default' after 12 μs
[14:11:53] Reloaded gulpfile.js
[14:12:11] Reloaded index.html
[14:13:05] Reloaded index.html
[14:13:15] Reloaded index.html
[14:13:52] Reloaded index.html
[14:14:13] Reloaded index.html
^[[15~[14:14:41] Reloaded index.html
[14:14:47] Reloaded index.html
[14:15:38] Reloaded index.html
[14:23:53] Starting 'styles'...
[14:23:53] Finished 'styles' after 19 ms
[14:23:53] Reloaded styles.css
[14:23:53] Reloaded normalize-min.css
[14:23:53] Reloaded styles-min.css
[14:23:53] Reloaded normalize-min.css
[14:23:53] Reloaded styles-min.css

但是浏览器本身并没有刷新,是什么情况?

回到顶部