gulp-autoprefixer报错‘autoprefixer is not a function’排查求助
gulp-autoprefixer报错‘autoprefixer is not a function’排查求助
各位大佬好,我碰到个闹心的问题:这套Gulp代码我在其他项目里跑都顺得很,但这次运行clean_makes_css任务时,直接抛出了autoprefixer is not a function的错误。
我特意加了个checkFunc任务排查模块加载情况,结果发现gulp-concat是正常的函数类型,但gulp-autoprefixer就不是。我已经确认gulp-autoprefixer包已经安装成功了,项目依赖里能看到它,可就是没法正常调用,实在搞不懂哪里出问题了,有没有过来人给指条路?
我的代码如下:
var gulp = require('gulp'); var concat = require('gulp-concat'); var autoprefixer = require('gulp-autoprefixer'); var css_minify = require('gulp-clean-css'); gulp.task('checkFunc', function (){ if (typeof concat === 'function'){ console.log('concat is a function'); }else { console.log('concat is not a function'); } if (typeof autoprefixer === 'function'){ console.log('autoprefixer is a function'); }else { console.log('autoprefixer is not a function'); } }); gulp.task('clean_makes_css', function () { // return gulp.src(['common_css/upper_section.css', 'common_css/popup.css', 'common_css/make.css', 'common_css/cart.css', 'common_css/login.css', 'common_css/receipt.css', 'common_css/orderhistory.css', 'common_css/google_translate.css']) return gulp.src(['common_css/upper_section.css', 'common_css/popup.css']) .pipe(concat('makes.min.css')) .pipe(autoprefixer('last 3 versions')) .pipe(css_minify({ keepbreaks: true })) .pipe(gulp.dest('dest_css')); });
对了,我装的是最新版的gulp-autoprefixer,会不会是和当前Gulp版本不兼容?或者是调用方式悄悄改了?我之前一直都是这么写的啊...
内容来源于stack exchange
相关产品推荐
相关产品推荐

