【问题标题】:Octopack won't package ng build output when there are subfolders当有子文件夹时,Octopack 不会打包 ng build 输出
【发布时间】:2017-04-19 17:16:04
【问题描述】:

这里的 gulp-octo 版本是 0.0.10,不再是当前版本。这可能适用于也可能不适用于较新的版本

angular-cli 命令ng-build 将我的 Angular 应用程序构建到 /dist 文件夹中。

我最终得到一个平面 dist 文件夹,其中包含我的 js、html 等文件。

/dist
  index.html
  inline.js
  [etc]

然后我可以使用gulp-octo 将我的包发布到我的章鱼部署主机,如下所示:

// You need to bump version in package.json and ng build before running this
gulp.task("publish", function() {
    return gulp.src(["dist/**"])
        .pipe(octo.pack())
        .pipe(octo.push(octoConfig));
});

哪个有效。

然后我将文件assetFile.png 添加到资产文件中。这会改变 /dist 的外观。它不再是完全平坦的:

/dist
   /assets
      assetFile.png
  index.html
  inline.js
  [etc]

突然之间,gulp publish 因以下错误而失败:

λ gulp publish
[11:14:58] Using gulpfile C:\Source\blank-angular-cli-app\gulpfile.js
[11:14:58] Starting 'publish'...
[11:14:58] Packed 'foo.0.0.0.2.tar.gz' with 10 files
C:\Source\blank-angular-cli-app\node_modules\@octopusdeploy\octopackjs\lib\pack.js:26
    throw err;
    ^

Error: ENOENT: no such file or directory, stat 'C:\Source\blank-angular-cli-app\assets'
    at Error (native)

它显然对包含子文件夹的 /dist 文件夹不满意(如果我在构建后将文件夹添加到 dist 中,我会得到同样的错误)。但我不确定为什么,以及如何处理。

发生了什么事?如何修复此部署?

Github 上的一个最小示例是我使用 ng init (angular-cli) 创建的空白应用程序,然后添加了 gulp 和 octopus。

【问题讨论】:

  • 解决了这个问题,很快就会回答。我认为 gulp-octo 中的错误。

标签: angular angular-cli octopus-deploy octopack


【解决方案1】:

所以解决方法是在顶层添加一个 assets/ 文件夹。

- assets
    unrelatedDoesntMatter.png
- dist
  - assets
    assetFile.png
[etc]

这里是commit that fixes my example app。这个文件夹无关紧要,也不会被打包。它只需要存在。奇怪,看起来像 gulp-octo 中的一个错误。

【讨论】:

    【解决方案2】:

    如果您更改 gulp.js 文件中的第 20 行

    return gulp.src(["dist/**"])
    

    return gulp.src(["dist/**"], { "base" : "." })
    

    它会起作用的。 gulp.src 的第二个参数告诉它获取所有目录。有关更多信息,请参阅此帖子:How do I copy directories recursively with gulp?

    【讨论】:

      猜你喜欢
      • 2019-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-14
      • 2022-09-29
      • 2018-05-13
      • 2011-05-29
      相关资源
      最近更新 更多