【问题标题】:Gulpfile relative path to rootGulpfile 到根目录的相对路径
【发布时间】:2017-03-24 13:22:42
【问题描述】:

我想从我的 gulpfile 访问我的部署文件夹,我将 gulpfile 放在源文件夹中,以便它保持整洁。我当前的文件夹结构:

deploy
├── js
├── css
├── img
└── index.php
source
├── node_modules
├── base
├── structure
└── gulpfile.js

上面的结构只是完整树的一部分

gulpfile.js 的一部分:

var path = {
    js: {
        src: [
            './source/_base/**/js/*.js',
            './source/_structure/**/js/*.js'
        ],
        deploy: [
            '../deploy/js/'
        ]
    },
// more below this line

gulp 任务:

gulp.task('process-js', function(){
    gulp.src(path.js.src)
    .pipe(plumber())
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
    .pipe(concat('main.min.js'))
    .pipe(uglify())
    .pipe(plumber.stop())
    .pipe(gulp.dest(path.js.deploy));
});

当我执行我的 gulp 任务(使用此部署路径)时,我收到一个错误:
:Error: Invalid output folder at Gulp.dest

问题:
如何使用 gulpfile 相对路径将文件放置在根文件夹的父级中。

【问题讨论】:

  • 我不知道你要传递给gulp.dest(),但绝对不是'../deploy/js/'。
  • 忘记添加那段代码,编辑问题
  • 好吧,这就是你的问题。 path.js.deploy 是一个数组,而不是一个字符串。
  • 谢谢,问题解决了!

标签: gulp


【解决方案1】:

我找到了解决方案,当然,无法将数组解析为目标。

【讨论】:

    猜你喜欢
    • 2011-12-19
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-27
    • 2016-01-12
    • 2012-07-21
    相关资源
    最近更新 更多