Browser-Sync 未将 CSS 注入浏览器
Browser-Sync not injecting CSS into Browser
我直到最近才使用这个 gulp 文件。现在一切仍然有效,CSS 仍然被编译,除了将编译的 CSS 注入浏览器。
感谢您的宝贵时间!
var gulp = require('gulp');
var gutil = require('gulp-util');
var bs = require('browser-sync').create();
// Include plugins
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var less = require('gulp-less');
var minifycss = require('gulp-clean-css');
var streamqueue = require('streamqueue');
gulp.task('bs', function () {
var files = [
'libraries/file1.css',
];
bs.init(files, {
proxy: 'localhost',
port: '80',
baseDir: './',
startPath: 'joomla'
})
gulp.watch("libraries/file1.css", ['fcss']);
});
gulp.task('fcss', function() {
var themes = ['.theme1','.theme2', '.theme3'];
themes.forEach( function(theme) {
return gulp.src(['libraries/'+theme+'.css',
'libraries/file1.css'
])
.pipe(concat('style'+theme+'.css'))
.pipe(gulp.dest('media/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss({advanced:false, keepSpecialComments : 0}))
.pipe(gulp.dest('media/css'))
.pipe(bs.stream());
});
});
在缩小之前尝试 运行 browsersync css:
gulp.task('fcss', function() {
var themes = ['.theme1','.theme2', '.theme3'];
themes.forEach( function(theme) {
return gulp.src(['libraries/'+theme+'.css',
'libraries/file1.css'
])
.pipe(concat('style'+theme+'.css'))
.pipe(bs.stream())
.pipe(gulp.dest('media/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss({advanced:false, keepSpecialComments : 0}))
.pipe(gulp.dest('media/css'));
});
});
我直到最近才使用这个 gulp 文件。现在一切仍然有效,CSS 仍然被编译,除了将编译的 CSS 注入浏览器。
感谢您的宝贵时间!
var gulp = require('gulp');
var gutil = require('gulp-util');
var bs = require('browser-sync').create();
// Include plugins
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var less = require('gulp-less');
var minifycss = require('gulp-clean-css');
var streamqueue = require('streamqueue');
gulp.task('bs', function () {
var files = [
'libraries/file1.css',
];
bs.init(files, {
proxy: 'localhost',
port: '80',
baseDir: './',
startPath: 'joomla'
})
gulp.watch("libraries/file1.css", ['fcss']);
});
gulp.task('fcss', function() {
var themes = ['.theme1','.theme2', '.theme3'];
themes.forEach( function(theme) {
return gulp.src(['libraries/'+theme+'.css',
'libraries/file1.css'
])
.pipe(concat('style'+theme+'.css'))
.pipe(gulp.dest('media/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss({advanced:false, keepSpecialComments : 0}))
.pipe(gulp.dest('media/css'))
.pipe(bs.stream());
});
});
在缩小之前尝试 运行 browsersync css:
gulp.task('fcss', function() {
var themes = ['.theme1','.theme2', '.theme3'];
themes.forEach( function(theme) {
return gulp.src(['libraries/'+theme+'.css',
'libraries/file1.css'
])
.pipe(concat('style'+theme+'.css'))
.pipe(bs.stream())
.pipe(gulp.dest('media/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss({advanced:false, keepSpecialComments : 0}))
.pipe(gulp.dest('media/css'));
});
});