gulp: сбой PostCSS - версия postcss выше, чем версия postcss-import

Я пытаюсь преобразовать свой CSS с помощью PostCss, используя Gulp.

Когда я добавляю плагин 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-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. Так что я должен делать?


person xooback    schedule 15.03.2018    source источник


Ответы (1)


Я нашел ответ:

Согласно веб-сайту cssnext, пакет cssnext (который я использовал) мертв. Новый пакет для использования с PostCSS - postcss-cssnext:

const postCssPlugins = [
    require('postcss-cssnext')()
];
person xooback    schedule 16.03.2018