Gatsby/Netlify 项目不在 git 存储库的根目录中

Gatsby/Netlify project not in root of git repo

关于问题前提是否是个坏主意的 XY 问题讨论的注释,请参阅此处:Git repo containing BackEnd and FrontEnd


我的 git 存储库如下所示:

root
|
|- .git\
|
|- JSFrontEnd\
|             |- package.json
|             |- tsconfig.json
|             |- .cache\
|             |- node_modules\
|             |- public\
|             |- src\
|             |- static\
|
|- C#BackEnd\
|
\_ .gitignore

JSFrontEnd 文件夹的内容是标准的 Gatsby/Netlify 项目结构,只是不在 repo 根目录中。

Netlify 似乎不喜欢这个 - 它想要 运行 gatsby build 在 repo root 上,但当然那是行不通的 - gatsby 不不知道该怎么办,因为没有 package.json.

我该如何告诉 Gatsby/Netlify 如何使用这个 repo 结构?

我对方法的第一个想法包括:

您可以使用 netlify.toml 文件来指定构建设置。在你的情况下,尝试:

# Global settings applied to the whole site.  
# 
# “publish” is the directory to publish (relative to root of your repo),
# “command” is your build command,
# “base” is directory to change to before starting build. if you set base:
#    that is where we will look for package.json/.nvmrc/etc not repo root!

[build]
  base    = "JSFrontEnd"
  publish = "JSFrontEnd/public"
  command = "gatsby build"