从蔚蓝的开发OPS管道建设gatsbyjs网站

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

我试图建立一个盖茨比静态的网站从Azure的开发建设OPS定义。

AzureDev OPS提供了一大口的任务,所以我试图创建一个简单的gulpfile包裹盖茨比的构建过程。

现在,我想:

const gatbsyCli = require('gatsby-cli/lib/create-cli');

function gatsbyBuild() {
    gatbsyCli([ 'build' ]);
}

exports.gatsbyBuild = gatsbyBuild;

但是,这项任务只显示命令行帮助:

Usage: gulp.js <command> [options]

Commands:
  gulp.js develop                   Start development server. Watches files, rebuilds, and hot reloads if something
                                    changes
  gulp.js build                     Build a Gatsby project.
  gulp.js serve                     Serve previously built Gatsby site.
  gulp.js info                      Get environment information for debugging and issue reporting
  gulp.js repl                      Get a node repl with context of Gatsby environment, see (add docs link here)
  gulp.js new [rootPath] [starter]  Create new Gatsby project.

Options:
  --verbose      Turn on verbose output                                                       [boolean] [default: false]
  --no-color     Turn off the color in output                                                 [boolean] [default: false]
  -h, --help     Show help                                                                                     [boolean]
  -v, --version  Show version number                                                                           [boolean]

Pass --help to see all available commands and options.
[22:28:15] The following tasks did not complete: gatsbyBuild
[22:28:15] Did you forget to signal async completion?

如何建立从一口一个盖茨比的网站?

有没有更好的办法来达到我的目标是什么?

[编辑]也试过:

const gatbsyBuildImpl = require('gatsby/dist/commands/build.js');

function gatsbyBuild() {
    gatbsyBuildImpl();
}

exports.gatsbyBuild = gatsbyBuild;

但失败TypeError: Cannot read property 'openTracingConfigFile' of undefined

[/编辑]

[编辑2019年2月2日]关于答案,这里是对我的最新进展。

首先,我尝试使用NPM行动来建立网站,为suggested

但是,它失败,出现以下错误:

2019-02-02T21:13:22.3306376Z [command]/usr/local/bin/npm run build
2019-02-02T21:13:27.6097839Z error GraphQL Error There was an error while compiling your site's GraphQL queries.
2019-02-02T21:13:27.6098171Z 
2019-02-02T21:13:27.6099612Z   Error: RelayParser: Encountered duplicate defintitions for one or more documents: each document must have a unique name. Duplicated documents:
2019-02-02T21:13:27.6100019Z > [email protected] build /home/vsts/work/1/s
2019-02-02T21:13:27.6100847Z - DefaultSEOQuery
2019-02-02T21:13:27.6100902Z > gatsby build

不过,我不明白这个错误。该网站完全建立在本地。

我的盖茨比 - node.js的查询是:

            `
{
  allMarkdownRemark(sort: {fields: [frontmatter___date], order: DESC}, limit: 1000) {
    edges {
      node {
        fields {
          slug
        }
        frontmatter {
          title
        }
      }
    }
    cats: group(field: frontmatter___categories, limit:1000) {
      fieldValue
      totalCount
    }
    tags: group(field: frontmatter___tags, limit:1000) {
      fieldValue
      totalCount
    }
  }
}

另外,这里是我的YAML定义:

resources:  
- repo: self    
queue:    
  name: Hosted Ubuntu 1604    
  demands: npm

steps:    
- task: Npm@1    
  displayName: 'npm install'    
  inputs:    
    verbose: false       

- task: Npm@1    
  displayName: 'npm custom'    
  inputs:    
    command: custom        
    verbose: false  
    customCommand: 'run build'

移动到“托管”代理,抛出另一个错误:

019-02-02T21:52:17.2419822Z [0m
2019-02-02T21:52:17.2419867Z [0m  [0m[97m[41mError[0m[37m[41m:[0m[37m[41m [0m[97m[41m0-0cf4e58448448331aa6c.js from Terser[0m
2019-02-02T21:52:17.2421623Z [0m  [0m[97m[41mTypeError: Cannot read property 'minify' of undefined[0m
2019-02-02T21:52:17.2421678Z [0m  [0m[97m[41m    at minify (D:\a\1\s\node_modules\terser-webpack-plugin\dist\minify.js:175:[0m  [0m[97m[41m22)[0m
2019-02-02T21:52:17.2421746Z [0m  [0m[97m[41m    at TaskRunner.boundWorkers.error [as boundWorkers] (D:\a\1\s\node_modules\[0m  [0m[97m[41mterser-webpack-plugin\dist\TaskRunner.js:68:40)[0m
2019-02-02T21:52:17.2421794Z [0m  [0m[97m[41m    at enqueue (D:\a\1\s\node_modules\terser-webpack-plugin\dist\TaskRunner.js[0m  [0m[97m[41m:89:14)[0m
2019-02-02T21:52:17.2421841Z [0m  [0m[97m[41m    at tryCatcher (D:\a\1\s\node_modules\bluebird\js\release\util.js:16:23)[0m
2019-02-02T21:52:17.2421906Z [0m  [0m[97m[41m    at Promise._settlePromiseFromHandler (D:\a\1\s\node_modules\bluebird\js\re[0m  [0m[97m[41mlease\promise.js:512:31)[0m
2019-02-02T21:52:17.2421954Z [0m  [0m[97m[41m    at Promise._settlePromise (D:\a\1\s\node_modules\bluebird\js\release\promi[0m  [0m[97m[41mse.js:569:18)[0m
2019-02-02T21:52:17.2422390Z [0m  [0m[97m[41m    at Promise._settlePromise0 (D:\a\1\s\node_modules\bluebird\js\release\prom[0m  [0m[97m[41mise.js:614:10)[0m
2019-02-02T21:52:17.2422463Z [0m  [0m[97m[41m    at Promise._settlePromises (D:\a\1\s\node_modules\bluebird\js\release\prom[0m  [0m[97m[41mise.js:690:18)[0m
2019-02-02T21:52:17.2422512Z [0m  [0m[97m[41m    at _drainQueueStep (D:\a\1\s\node_modules\bluebird\js\release\async.js:138[0m  [0m[97m[41m:12)[0m
2019-02-02T21:52:17.2422560Z [0m  [0m[97m[41m    at _drainQueue (D:\a\1\s\node_modules\bluebird\js\release\async.js:131:9)[0m
2019-02-02T21:52:17.2422626Z [0m  [0m[97m[41m    at Async._drainQueues (D:\a\1\s\node_modules\bluebird\js\release\async.js:[0m  [0m[97m[41m147:5)[0m
2019-02-02T21:52:17.2422677Z [0m  [0m[97m[41m    at Immediate.Async.drainQueues (D:\a\1\s\node_modules\bluebird\js\release\[0m  [0m[97m[41masync.js:17:14)[0m
2019-02-02T21:52:17.2422769Z [0m  [0m[97m[41m    at runCallback (timers.js:637:20)[0m
2019-02-02T21:52:17.2422832Z [0m  [0m[97m[41m    at tryOnImmediate (timers.js:610:5)[0m
2019-02-02T21:52:17.2422878Z [0m  [0m[97m[41m    at processImmediate [as _immediateCallback] (timers.js:582:5)[0m

npm ERR! Failed at the [email protected] build script 'gatsby build'.
2019-02-02T21:52:17.2430701Z npm ERR! Make sure you have the latest version of node.js and npm installed.
2019-02-02T21:52:17.2430849Z npm ERR! If you do, this is most likely a problem with the gatsby-starter-blog package,
2019-02-02T21:52:17.2431116Z npm ERR! not with npm itself.
gulp azure-devops gatsby
1个回答
2
投票

你可以简单地使用NPM。两个构建步骤是不够的第一个开始:

  1. 安装依赖 npm install
  2. 建立 npm run build

之前,你可以做你的package.json需要以下脚本(这是每个gatsbyJS样板提供):

enter image description here

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