除自动前缀外,所有其他功能均正常运行。 BrowserSync正在重新加载,在sass文件中显示了devTools行,但是不幸的是,当我尝试应用一些flexbox时,在我的目标文件main.css中,autoprefixer无效。你能帮我吗?
const gulp = require('gulp');
const sass = require('gulp-sass');
const browserSync = require('browser-sync').create();
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
// compile scss into css
function style() {
// 1. where is my scss file
return gulp.src('./scss/**/*.scss')
// 2. pass that file through sass compiler & error log
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(autoprefixer({browsers: ['last 2 version'], cascade: false})
// 3. where do I save the compiled CSS?
.pipe(gulp.dest('./css'))
// 4. stream changes to all browser
.pipe(browserSync.stream()))
}
function watch() {
browserSync.init({
server: {
baseDir: './'
}
});
gulp.watch('./scss/**/*.scss', style);
gulp.watch('./*.html').on('change', browserSync.reload);
gulp.watch('./js/*.js').on('change', browserSync.reload);
}
exports.style = style;
exports.watch = watch;