1

私の人生では、この構成の何が問題なのかをどうにかして見つけることができません! master.css の変更を注入した後、変更を反映するだけでなく、ブラウザー ウィンドウが自動的にリロードされますが、"injected" と表示されます。誰か助けてくれませんか?次の構成の gulpfile.js があります。

var paths = {
master: {
    styles: 'default/less/master.less',
},
watch: {
    styles: 'default/less/**/*.less',
},
dist: {
    styles: 'default/less',
}
};

より少ないタスク:

gulp.task('less', function(){
'use strict';
gulp.src(paths.master.styles)
.pipe(sourcemaps.init())
.pipe(plumber())
.pipe(less({compress:false})) 
.on('error', function (err) {
        gutil.log(err);
        this.emit('end');
 })
 .pipe(autoprefix())
 .pipe(sourcemaps.write('../sourcemaps', {
    includeContent: false, // Otherwise all the CSS would be included
    sourceRoot: paths.dist.styles
}))
.pipe(gulp.dest(paths.dist.styles))
.on('error', gutil.log)
.pipe(browserSync.stream());
});

Browsersync タスク:

gulp.task('browser-sync', ['less'], function() {
'use strict';
browserSync.init({
    proxy: "http://mywebsite.local",
    stream:true
});
gulp.watch(paths.watch.styles, ['less']);
});

そして最後に:

gulp.task('default', ['less', 'browser-sync']);

変更が挿入されたという通知が表示されます。端末には master.css と master.css.map が変更されたと表示され、less ファイルの変更も反映されますが、どういうわけかブラウザがリロードされます。 css コンパイル。

4

0 に答える 0