我试图使用Gulp用PostCss转换我的css。
当我将 cssnext 插件添加到 PostCss 时,出现以下错误:
Unknown error from PostCSS plugin. Your current PostCSS version is 6.0.19, but postcss-import uses 4.1.16. Perhaps this is the source of the error below.
这是我gulpfile.js
:
const gulp = require('gulp');
const postcss = require('gulp-postcss');
const concat = require('gulp-concat');
gulp.task('styles', function() {
const postCssPlugins = [
require('cssnext')()
];
gulp.src('src/css/*.css')
.pipe(postcss(postCssPlugins))
.pipe(concat('style.css'))
.pipe(gulp.dest('.'));
});
全栈跟踪:
events.js:183
throw er; // Unhandled 'error' event
^
TypeError: styles.eachAtRule is not a function
at parseStyles (C:gulp-testnode_modulescssnextnode_modulespostcss-importindex.js:134:10)
at C:gulp-testnode_modulescssnextnode_modulespostcss-importindex.js:84:30
at LazyResult.run (C:gulp-testnode_modulespostcssliblazy-result.js:277:20)
at LazyResult.asyncTick (C:gulp-testnode_modulespostcssliblazy-result.js:192:32)
at processing.Promise.then._this2.processed (C:gulp-testnode_modulespostcssliblazy-result.js:231:20)
at new Promise (<anonymous>)
at LazyResult.async (C:gulp-testnode_modulespostcssliblazy-result.js:228:27)
at LazyResult.then (C:gulp-testnode_modulespostcssliblazy-result.js:134:21)
at process._tickCallback (internal/process/next_tick.js:188:7)
据我所知,postcss-import 包是 cssnext 的依赖项。那我该怎么办?
我找到了答案:
根据cssnext的网站,cssnext软件包(我使用的(已经死了。与PostCSS一起使用的新包是postcss-cssnext
:
const postCssPlugins = [
require('postcss-cssnext')()
];