Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating publish and functions directories for production build #141

Closed
MikeM2343 opened this issue Mar 15, 2021 · 2 comments
Closed
Labels
priority: high type: bug code to address defects in shipped code

Comments

@MikeM2343
Copy link

MikeM2343 commented Mar 15, 2021

Describe the bug

  1. The build fails on the netlify server saying that the Web/out_functions and Web/out_publish directories do not exist
  2. The netlify build process never finishes (stays at "building"), requiring you to "Cancel Deploy"

To Reproduce
Steps to reproduce the behavior:

  1. Mono repo containing libraries and the main web app
  2. Trigger the deploy that runs a script in the root of the repo that builds the libraries and then builds the main Next app

Expected behavior
The app builds without any errors

Versions

  • Next.js: 10.0.8
  • plugin (if installed at fixed version): 3.0.3

If you're using file-based installation
**netlify.toml: **

[build]
  command   = "yarn lerna run build"
  functions = "Web/out_functions"
  publish   = "Web/out_publish"

[dev]
  functions = "Web/out_functions"
  publish   = "Web/out_publish"
  autoLaunch = false
  command = "yarn run dev"
  targetPort = 3000
  framework = "#custom"

  [[plugins]]
  package = "@netlify/plugin-nextjs" 

Failed Build file
NetlifyBuild.log

Hello,

I'm not sure I have the correct netlify.toml configuration for the monorepo. I'm pretty sure I shouldn't be specifying a base directory because I need to run a script to build both my libraries and the main app from the root of the repo.

Is there any way to test this locally? I know that when using next-on-netlify, and doing a build, the out_publish and out_functions directories were created on my local system.

Thanks,
Mike

@MikeM2343
Copy link
Author

MikeM2343 commented Mar 16, 2021

I've done a bit more digging and here's what I've found

  • the Netlify deploy was not picking up the @netlify/plugin-nextjs plugin from the toml file in the Web directory as per the structure below
  • When I added the netlify plugin via the Netlify UI and reran the deploy, I got a different error as indicated in this log:
    NetlifyBuild2.log
  • I tried running "netlify build" locally. With debugging, I found that the plugin.onBuild was passed the proper PUBLISH_DIR, and FUNCTIONS_SRC constants (Web\out_publish and Web\out_functions) as per the toml file, but that the publish and functions properties of netlifyConfig had an extra 'Web' directory part in it. i.e. <rootDir>\Web\Web\out_publish. This may not be the case in a web-based deploy, but it does seem to be the case for a local 'netlify build'. The netlifyConfig object also had 'base' set to <rootDir>\Web. I have not set the "base" property of the netlify.toml or in the Netlify Web UI because I need to run the build script from the root directory.

My monorepo directory structure

/
| -- libs/
|    | -- lib1
|    | -- lib2
|    | -- ...
| -- Web/
|    | -- src/
|    | -- netlify.toml
|    | -- package.json 
| -- package.json (for lerna stuff)

The 'yarn lerna run build' builds all the libraries in libs and lastly runs yarn build in the Web directory, which runs 'next build'

@lindsaylevine lindsaylevine added the type: bug code to address defects in shipped code label Mar 19, 2021
@lindsaylevine lindsaylevine added this to the Monorepo support milestone Mar 21, 2021
@lindsaylevine
Copy link

hey @MikeM2343! thanks for your patience on this. we're finally getting to work on these greater monorepo issues. we're consolidating everyone's issues into #433, so we'll close this in favor of that. please follow along there, but we'll try to circle back here, too, whenever we release support! 🙏

serhalp pushed a commit that referenced this issue Apr 5, 2024
* test: add unit test cases for basePath

* test: add integration tests for placing static assets in publish dir (for no basePath and for basePath)

* fix: support basepath for static assets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants