“ dest.on不是函数”,使用带gulp v4的postcss-rtl

问题描述 投票:0回答:1

我正在尝试使用postcss-rtl将CSS文档转换为rtl(从右到左),并使用gulp将其自动化。这是我在运行gulp watch时遇到的错误:

TypeError: dest.on is not a function
    at DestroyableTransform.Readable.pipe (D:\Projects\BootstrapRTL\node_modules\readable-stream\lib\_stream_readable.js:564:8)
    at rtlize (D:\Projects\BootstrapRTL\gulpfile.js:39:8)
    at rtlize (D:\Projects\BootstrapRTL\node_modules\undertaker\lib\set-task.js:13:15)
    at bound (domain.js:422:14)
    at runBound (domain.js:435:12)
    at asyncRunner (D:\Projects\BootstrapRTL\node_modules\async-done\index.js:55:18)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

这是我的特定功能代码:

const gulp = require("gulp");
const postcss = require("postcss");
const rtl = require("postcss-rtl");

function rtlize() {
  return (
    // 1. Get the css file
    gulp
      .src("./css/main.css")
      // 2. Rtlize the css file
      .pipe(postcss(rtl()))
      // 3. Export the css file
      .pipe(gulp.dest("./css/rtl"))
  );
}

exports.rtlize = rtlize;
javascript gulp gulp-sass postcss
1个回答
0
投票

更改此:

请参见https://www.npmjs.com/package/postcss-rtl#with-gulp;来自文档:

.pipe( postcss( [ rtl( options ) ]) )  // should be like this

注意rtl在数组中。并非您所拥有的.pipe(postcss(rtl()))

© www.soinside.com 2019 - 2024. All rights reserved.