Skip to content

Commit 76edc53

Browse files
feat: add support for use with next export (#1012)
* feat: add support for env var to skip running plugin * chore: add demo Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 1c5701a commit 76edc53

File tree

20 files changed

+382
-4
lines changed

20 files changed

+382
-4
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ If you are using Nx, then you will need to point `publish` to the folder inside
7676
The Essential Next.js plugin now fully supports ISR on Netlify. For more details see
7777
[the ISR docs](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/isr.md).
7878

79+
## Use with `next export`
80+
81+
If you are using `next export` to generate a static site, you do not need most of the functionality of this plugin and
82+
you can remove it. Alternatively you can
83+
[set the environment variable](https://docs.netlify.com/configure-builds/environment-variables/)
84+
`NETLIFY_NEXT_PLUGIN_SKIP` to `true` and the plugin will handle caching but won't generate any functions for SSR
85+
support. See [`demos/next-export`](https://github.com/netlify/netlify-plugin-nextjs/tree/main/demos/next-export) for an
86+
example.
87+
7988
## Feedback
8089

8190
If you think you have found a bug in the plugin,

demos/next-export/.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "next",
3+
"root": true
4+
}

demos/next-export/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel

demos/next-export/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is an example of a site that uses `next export`. It only uses the plugin for cache handling and sets
2+
`NETLIFY_NEXT_PLUGIN_SKIP` to disable everything else.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../../lib')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: '@netlify/plugin-nextjs-local'

demos/next-export/local-plugin/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "local-plugin",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"preinstall": "cd ../../.. && npm i"
8+
},
9+
"author": "",
10+
"license": "ISC"
11+
}

demos/next-export/netlify.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[build]
2+
command = "next build && next export"
3+
publish = "out"
4+
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../../"
5+
6+
[build.environment]
7+
NETLIFY_NEXT_PLUGIN_SKIP = "true"
8+
9+
[dev]
10+
framework = "#static"
11+
12+
[[plugins]]
13+
package = "./local-plugin"
14+
15+
[[plugins]]
16+
package = "@netlify/plugin-local-install-core"

demos/next-export/next.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
// Configurable site features we support:
3+
// distDir: 'build',
4+
generateBuildId: () => 'build-id',
5+
}

0 commit comments

Comments
 (0)