我无法让Autoprefixer与Gulp合作.我在CSS,渐变和变换中使用不透明度,并且没有任何供应商前缀出现.否则,其他一切正常.
这是我的gulp文件:
var gulp = require('gulp'); var lr = require('tiny-lr'); var jshint = require('gulp-jshint'); var sass = require('gulp-sass'); var autoprefixer = require('gulp-autoprefixer'); var minifycss = require('gulp-minify-css'); var concat = require('gulp-concat'); var rename = require('gulp-rename'); var livereload = require('gulp-livereload'); var server = lr(); var plumber = require('gulp-plumber'); var onError = function (err) { gutil.beep(); console.log(err); }; gulp.task('lint',function() { return gulp.src('js/all.js') .pipe(jshint()) .pipe(jshint.reporter('default')); }); gulp.task('sass',function() { return gulp.src('scss/*.scss') .pipe(sass({errLogToConsole: true})) .pipe(autoprefixer('last 2 versions','safari 5','ie6','ie7','ie 8','ie 9','opera 12.1','ios 6','android 4')) .pipe(minifycss()) .pipe(gulp.dest('')) .pipe(plumber({ errorHandler: onError })) .pipe(livereload(server)); }); gulp.task('scripts',function() { return gulp.src(['js/fittext.js','js/fitvids.js','js/snap-scroll.js','js/cycle-min.js','js/all.js','js/respond.js']) .pipe(concat('all.js')) .pipe(gulp.dest('js/min')) .pipe(rename('main.min.js')) .pipe(gulp.dest('js/min')) .pipe(plumber({ errorHandler: onError })) .pipe(livereload(server)); }); gulp.task('watch',function() { livereload.listen(); gulp.watch('**/*.PHP').on('change',livereload.changed); gulp.watch('js/*.js',['scripts']); gulp.watch('scss/**/*.scss',['sass']); }); gulp.task('default',['lint','sass','scripts','watch']);
>我搜索并尝试了各种解决方案,但无济于事.我也尝试将.pipe(gulp.dest(”))更改为特定目录(如this answer suggested),没有任何运气.
我感谢您提供的任何帮助.
*更新*
我想注意我在Autoprefixer上为不透明度添加前缀的天真,这显然不是.
解决方法
@H_502_17@ 这个gulpfile:var gulp = require('gulp'); var sass = require('gulp-sass'); var prefix = require('gulp-autoprefixer'); var minify = require('gulp-minify-css'); var plumber = require('gulp-plumber'); function onError(err) { console.log(err); } gulp.task('sass',function(){ return gulp.src('src/style.scss') .pipe(sass()) .pipe(prefix('last 2 versions')) .pipe(minify()) .pipe(gulp.dest('css/')) .pipe(plumber({ errorHandler: onError })) });
有了这个scss:
body { opacity: .5; Box-sizing: border-Box; transform: scale(.5); display: flex; }
body{opacity:.5;Box-sizing:border-Box;-webkit-transform:scale(.5);-ms-transform:scale(.5);transform:scale(.5);display:-webkit-Box;display:-webkit-flex;display:-ms-flexBox;display:flex}
所以,我不确定我的做法与众不同,只是我以不同方式列出我的浏览器.但我想你已经尝试删除那些等.