Custom file path option for next.config.js file through CLI commands #31433
Replies: 9 comments 1 reply
-
I was seeking this This would be a very simple "monorepo", reusing components and package configurations (eslint, tailwind, jest, ..) and just filtering pages at export time. |
Beta Was this translation helpful? Give feedback.
-
Agree. You should be able to specify next config on command line. We are trying to manage multiple projects from the same code base and each needs a separate config. |
Beta Was this translation helpful? Give feedback.
-
any updates? |
Beta Was this translation helpful? Give feedback.
-
any updates? |
Beta Was this translation helpful? Give feedback.
-
+1 I want this as well |
Beta Was this translation helpful? Give feedback.
-
Did you find any solution? |
Beta Was this translation helpful? Give feedback.
-
any updates? |
Beta Was this translation helpful? Give feedback.
-
Can we create an Issue for this ? Or... We can set an Env variable like how Bundle Analyzer is enabled ? and modify the values through that |
Beta Was this translation helpful? Give feedback.
-
I found a workaround. I wanted to be able to easily customize the output of my build. Initially I was looking for a way to have different config files but then I thought of environment variables. I setup my ...
"scripts": {
...
"build": "next build",
"export": "OUTPUT=export next build",
"start": "next start",
...
},
... Then in /** @type {import('next').NextConfig} */
const nextConfig = {
output: process.env.OUTPUT,
};
export default nextConfig; You could use a similar strategy to have any number of config objects that are used or ignored based on one or more environment variables. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the feature you'd like to request
When abstracting nextJS configs (say in the case of a multi nextJS app mono repo) it can be helpful if one could share a single config file between them. This requires the cli to expose an option for a custom config file path instead of (as I understand it) only being able to customise nextJS configs through a
next.config.js
file sitting at the app root.Describe the solution you'd like
Add support for a -config option or equivalent for cli commands
next dev -config [CUSTOM CONFIG FILE PATH]
next build -config [CUSTOM CONFIG FILE PATH]
next start -config [CUSTOM CONFIG FILE PATH]
Describe alternatives you've considered
One possible viable alternative I tried is Importing shared config into each apps next/config.js that is not the most elegant solution but also in my case failed with
Cannot use import statement outside a module
because all our configs leave in an external npm package.Beta Was this translation helpful? Give feedback.
All reactions