Replies: 4 comments 9 replies
-
Sure, you can use the const nextConfig = {
output: process.env.NEXT_OUTPUT_MODE,
exclude: [
'api',
'middleware',
],
}
module.exports = nextConfig This will tell Next.js to ignore the Here is a more detailed explanation of how the In your case, you want to ignore the I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
I find a workaround but maybe a built-in solution exist. I add have installed ignore-loader for webpack
Then i add following webpack property to my next.js.config const nextConfig = {
output: process.env.NEXT_OUTPUT_MODE,
webpack: config => {
if (process.env.NEXT_OUTPUT_MODE !== 'export' || !config.module) {
return config;
}
config.module.rules?.push({
test: /src\/app\/api/,
loader: 'ignore-loader',
});
return config;
},
} |
Beta Was this translation helpful? Give feedback.
-
I got the same error. |
Beta Was this translation helpful? Give feedback.
-
I guess the only real way to fix this is to write a script that copies these files out of your project, does a build, then copies them back. ROFL! C'mon.... Just ignore API routes on exports obviously! |
Beta Was this translation helpful? Give feedback.
-
Summary
I have a next13 project that need different build type depending on environnement variable.
I'm using "app" folder
Here is my next.config.js
I have api folder and middleware file that should be used when next is build with output "standalone"
Druring build on "export" mode I got following error
Any way to ignore "api" folder and "middleware" file during build when "output" is "export" ?
Reproducible repository
https://github.com/zeckaissue/next-export-api-crash/
Beta Was this translation helpful? Give feedback.
All reactions