首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gulp: PostCSS failing postcss版本高于postcss版本-导入

gulp: PostCSS failing postcss版本高于postcss版本-导入
EN

Stack Overflow用户
提问于 2018-03-15 21:32:46
回答 1查看 1.1K关注 0票数 0

我试着用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

代码语言:javascript
复制
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('.'));
});

全堆栈跟踪:

代码语言:javascript
复制
events.js:183
  throw er; // Unhandled 'error' event
  ^
TypeError: styles.eachAtRule is not a function
at parseStyles (C:\gulp-test\node_modules\cssnext\node_modules\postcss-import\index.js:134:10)
at C:\gulp-test\node_modules\cssnext\node_modules\postcss-import\index.js:84:30
at LazyResult.run (C:\gulp-test\node_modules\postcss\lib\lazy-result.js:277:20)
at LazyResult.asyncTick (C:\gulp-test\node_modules\postcss\lib\lazy-result.js:192:32)
at processing.Promise.then._this2.processed (C:\gulp-test\node_modules\postcss\lib\lazy-result.js:231:20)
at new Promise (<anonymous>)
at LazyResult.async (C:\gulp-test\node_modules\postcss\lib\lazy-result.js:228:27)
at LazyResult.then (C:\gulp-test\node_modules\postcss\lib\lazy-result.js:134:21)
at process._tickCallback (internal/process/next_tick.js:188:7)

据我所知,postcss-import包是cssnext的依赖项。那我该怎么办?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-16 18:26:29

我找到了答案:

根据下一次的网站,cssnext包(我用过)已经死了。与PostCSS一起使用的新包是postcss-cssnext

代码语言:javascript
复制
const postCssPlugins = [
    require('postcss-cssnext')()
];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49309596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档