Netlify:如何部署嵌套在文件夹中的站点? [英] Netlify: How do you deploy sites that are nested in a folder?

查看:82
本文介绍了Netlify:如何部署嵌套在文件夹中的站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个回购,在两个单独的文件夹中有后端和前端(create-react-app)。对于build命令,我有类似 cd frontend&&的内容。 npm运行build ,对于发布目录,我有类似 frontend / build 的东西,但这不起作用。

I have a repo that has the backend and frontend (create-react-app) in two separate folders. For the build command, I have something like cd frontend && npm run build and for the publish directory, I have something like frontend/build, but this is not working.

推荐答案

免责声明:我为Netlify工作。

disclaimer: I work for Netlify.

如果您要克隆 new复制(例如,在项目中未安装任何节点模块)到一台新的笔记本电脑上,除了节点和npm以外,别无其他,您将如何构建它?想象一下netlify的构建过程。因此,您至少缺少其中的 npm安装步骤:)

If you were to clone a new copy (no node modules installed in the project, for instance) of your project on a fresh laptop with nothing else except node and npm installed there, how would you build it? Imagine netlify's build process like that. So you're missing at least an "npm install" step in there :)

还有其他丢失的东西,例如全局安装的npm软件包?需要在 package.json 中指定它们,以便Netlify的构建网络知道为您抓住它们。红宝石宝石?最好在您的存储库中包含 Gemfile

Anything else missing, like globally installed npm packages? Need to specify them in package.json so that Netlify's build network knows to grab them for you. Ruby gems? Better have a Gemfile in your repo!

Netlify尝试 npm安装 package.json ,则会自动为您自动设置c $ c>(和捆绑安装)您的存储库(我想您的存储库位于 frontend / 吗?),或者如果您设置了 base参数,以便我们在基本目录中开始构建。这对您来说可能是一个很好的模式,将 base设置为 frontend ,然后将发布目录设置为 build

Netlify tries to npm install (and bundle install) automatically for you, assuming there is a package.json either in the root of your repository (I'm guessing yours is in frontend/ ?) OR if you set the "base" parameter so that we start our build in the base directory. This is probably a good pattern for you, to set "base" to frontend, and then set your publish directory to build.

您可以在 netlify.toml 像这样:


[build]
base =前端

请注意, netlify.toml 必须位于存储库的根目录中。

Note that netlify.toml must reside in the root of your repository.

有关Netlify如何构建的更多详细信息,请查看以下文章:

For more details on how Netlify builds, check out the following articles:

  • Overview of how our build network works. This article also shows how you can download our build image to test locally.
  • Settings that affect our build environment. Useful for telling us about what node version to use, for instance.
  • Some frequently experienced problems

如果经过一些阅读和实验,您仍然无法解决问题, 访问服务台

If after some reading and experimenting, you still can't figure things out, ping the helpdesk.

这篇关于Netlify:如何部署嵌套在文件夹中的站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆