javascript - gulp.src 基本选项应用于一个数组项

标签 javascript node.js gulp

我在我的 gulp.src
中使用了 base 选项 我希望基础将应用于我的 src array 中的 one item 但不应用于 rest:
就我而言:

   gulp.src(['./languages/*.json', '../../../Configuration/Client/help/*/**'],{base:'../../../Configuration/Client'})
                .pipe(zip('my_zip_file.zip'))
                .pipe(gulp.dest('./dist/'));

我需要 {base:'../../../Configuration/Client'}仅应用于数组中的第二项('../../../Configuration/Client/help/*/**') 并且不在第一项上

base 选项似乎不能按数组项分隔。

最佳答案

将以下内容添加到您的 npm 包中:event-stream

然后在你的 gulpfile.js 中:

  var eventStream = require('event-stream');
  var jsonFiles = gulp.src('./languages/*.json');
  var helpfiles = gulp.src('../../../Configuration/Client/help/*/**',{base:'../../../Configuration/Client'});

  eventStream.merge(jsonFiles,helpfiles)
      .pipe(zip('myZipFile.zip'))
      .pipe(gulp.dest('./languages/'))

关于javascript - gulp.src 基本选项应用于一个数组项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47868901/

相关文章:

javascript - 在 Javascript 中使用变量格式化字符串模板

node.js - 将带有表单的文件从 nuxt 发送到 Node 服务器(nodemailer)

javascript - Gulp - 错误 SyntaxError : Unexpected token

node.js - 无法安装 gulp-sass

node.js - 使用 nano 将二进制附件插入 CouchDB

css - gulp.dest 与当前文件相同?

javascript - 日期对象抛出无效的时区日期

javascript - Electron 不将 json 文件添加到应用程序

javascript - 仅使用 javascript 不使用 cookie : how? 进行年龄验证

javascript - Nodejs - socketio - 更新所有浏览器窗口中的信息