Smruti Gawde
Smruti Gawde

Reputation: 21

Build prod build for NextJs - (Static) automatically rendered as static HTML (uses no initial props)

Trying to create prod build with npm run build

but it outputs to

info - Creating an optimized production build info - Compiled successfully info - Collecting page data info - Generating static pages (5/5) info - Finalizing page optimization Page Size First Load JS

┌ ○ / 261 B 222 kB

├ /_app 0 B 222 kB

├ ○ /404 194 B 222 kB

├ ○ /dashboard 236 B 222 kB

└ ○ /sign-in 514 B 222 kB

○(Static) automatically rendered as static HTML (uses no initial props)

What is missing here? i dont see any build folder in project root, also is it successfull or not?

tried to npm run build

Expecting : successfull build and build folder in project root

Upvotes: 2

Views: 2908

Answers (2)

xiao
xiao

Reputation: 1

To enable a static export, change the output mode inside next.config.js:

/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  output: 'export',
 
}
 
module.exports = nextConfig

After running next build, Next.js will produce an out folder which contains the HTML/CSS/JS assets for your application.

For reference check out the Next JS Documentation

Upvotes: 0

kca
kca

Reputation: 6123

The "normal" output folder after next build would be /.next, which is not supposed to be touched during normal development, but instead should be used automatically by next.js with its included server, usually started with next start.

Alternatively you can create a static build with next export, and specify a custom output folder, but you have to setup a server yourself then.

Upvotes: 0

Related Questions