Skip to content

[Bug]: When using next export, cache not found #1192

@Redmega

Description

@Redmega

Summary

According to the docs, this plugin should be able to handle caching the build folder from a next exported project. However in practice, the plugin seems to be looking at the publish directory for the cache folder, which would not exist when you publish the out/ directory, like in the demo project.

https://github.com/netlify/netlify-plugin-nextjs/blob/b27c2f299c47ff387e726f76ad03847271e9d8e5/src/helpers/cache.ts#L13-L22

In this case you would want to cache the .next/cache folder, because the .next folder is what actually gets built -- the export command pulls the data it needs from the .next folder.

Steps to reproduce

  1. Publish the demo export
  2. Go to the logs
  3. See that it does not cache.

Plugin version

v4.2.3

Your netlify.toml file

`netlify.toml`
[build]
command = "yarn build" # "next build && next export"
publish = "out/"

[build.environment]
NETLIFY_NEXT_PLUGIN_SKIP = "true"

Builds logs (or link to your logs)

Build logs
1:38:19 PM:   2. build.command from netlify.toml                            
1:38:19 PM: ────────────────────────────────────────────────────────────────
[...]
1:38:19 PM: ​
 info  - using build directory: /opt/build/repo/.next
1:39:04 PM: info  - Copying "static build" directory
1:39:04 PM: info  - No "exportPathMap" found in "/opt/build/repo/next.config.js". Generating map from "./pages"
1:39:04 PM: info  - Launching 7 workers
1:39:04 PM: info  - Exporting (0/2)
1:39:04 PM: info  - Copying "public" directory
1:39:05 PM: info  - Exporting (2/2)
1:39:05 PM: Export successful. Files written to /opt/build/repo/out
1:39:05 PM: Done in 46.10s.
[...]

1:39:05 PM: ────────────────────────────────────────────────────────────────
1:39:05 PM:   4. @netlify/plugin-nextjs (onPostBuild event)                 
1:39:05 PM: ────────────────────────────────────────────────────────────────
1:39:05 PM: ​
1:39:05 PM: No Next.js cache to save.
1:39:05 PM: ​
1:39:05 PM: (@netlify/plugin-nextjs onPostBuild completed in 5ms)
1:39:05 PM: ​

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions