Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netlify: How do you deploy sites that are nested in a folder?

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.

like image 360
sdfsdf Avatar asked May 16 '18 07:05

sdfsdf


People also ask

How do I deploy a sub directory in Netlify?

using Netlify CLI when setting up continuous deployment for a site. Change to the subdirectory that you'd like to set as the base, then run the netlify init command. The current working directory is then specified as the base.

Does Netlify auto deploy?

While it's amazing that Netlify automatically deploys websites whenever code is pushed, sometimes you need deploys to happen on a more regular interval.

What is Netlify toml file?

The netlify. toml is a configuration file that specifies how Netlify builds and deploys your site — including redirects, branch and context-specific settings, and more.


1 Answers

disclaimer: I work for Netlify.

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 :)

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 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.

You can specify that base parameter in netlify.toml something like this:

[build] base = "frontend"

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

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.

like image 143
fool Avatar answered Oct 26 '22 15:10

fool