#Keep output and dev files separate

1 messages · Page 1 of 1 (latest)

livid frigate
#

I need to build my Next application with output: "export" and distDir: "out/web/". This does work partially, it does build correctly, but the dev files (dev server cache, trace, etc) use this folder too, which messes up my build pipeline. Can I make these paths separate?

This is the contents of out/web/ when a dev server has been running before building:

.well-known
404.html
_next
account.html
account.txt
app-build-manifest.json
auth
build-manifest.json
cache
index.html
index.txt
package.json
react-loadable-manifest.json
server
static
test-images
trace
types

while this is a clean build:

.well-known
404.html
_next
account.html
account.txt
auth
index.html
index.txt
test-images

(I have a custom setup with builds so I need to have a custom distDir set)

median narwhalBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

livid frigate
#

Just tried checking process.env.NODE_ENV inside of next.config.ts, and it does actually use development for next dev and production for next build, can I simply use that and only set distDir when process.env.NODE_ENV === "production"?

livid frigate
#

Welp, it seemed to actually work flawlessly..! My next.config.ts has now passed the "more-logic-than-config"-bar but it now does exactly what I want.

#

Solution is to add this check your config:

distDir: process.env.NODE_ENV === "production" ? "your/out/folder/" : undefined, // or change `undefined` to your preferred dev folder, or even more logic for multiple dev folders simultaneously ;)
#

(This is just what I found, there may be a better way to achieve this, but this is all I've got!)