Standalone output configured by ENV variable
Unanswered
West African Lion posted this in #help-forum
West African LionOP
Docs: https://nextjs.org/docs/app/api-reference/config/next-config-js/output#automatically-copying-traced-files
I can see,
This is great, but I cannot do this in my setup. Instead, I need to use environment variables.
Nuxt presets is great example of approach that would work great: https://nuxt.com/docs/getting-started/deployment#presets
Notice you provide environment variable alongside build command, to configure what build should look like.
Is there such an environment variable in Next.js I could use to configure build, similarly to how
I can see,
next.config.js
can include output: standalone
, to create standalone build.This is great, but I cannot do this in my setup. Instead, I need to use environment variables.
Nuxt presets is great example of approach that would work great: https://nuxt.com/docs/getting-started/deployment#presets
Notice you provide environment variable alongside build command, to configure what build should look like.
Is there such an environment variable in Next.js I could use to configure build, similarly to how
output
property would configure it in next.config.js
?3 Replies
West African Lion
during the build process, Next.js does not currently support an environment variable that replaces output: 'standalone'
The output config must be defined in next.config.js.
You can write in your next.config.js file.
const isStandalone = process.env.NEXT_PRESET === 'standalone';
module.exports = {
output: isStandalone ? 'standalone' : undefined,
};
const isStandalone = process.env.NEXT_PRESET === 'standalone';
module.exports = {
output: isStandalone ? 'standalone' : undefined,
};