直到最近我才使用这个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());
});
});
答案 0 :(得分:1)
在缩小css之前尝试运行browsersync:
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'));
});
});