'nextjs custom serve directory in production
The problem: When I run next build on my production server, the page is served unstyled while building.
What I want to do:
- build the app to
builddirectory - move
buildtobuild-public - serve the app from
build-public.
I don't want to setup a custom server for that simple task.
My package.json scripts section:
"scripts": {
"dev": "next dev -p 3002",
"build": "next build",
"start": "next start -p 3002"
},
My next.config.js:
module.exports = {
basePath: '',
distDir: 'build', // build to build
dir: 'build-public', // serve from build-public. 'Dir' option is not working.
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
