Skip to content

Commit d6e61c0

Browse files
authored
Update articles/static-web-apps/deploy-nextjs-hybrid.md
1 parent 1aaf895 commit d6e61c0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

articles/static-web-apps/deploy-nextjs-hybrid.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,32 @@ Next.js uses environment variables at build time and at request time, to support
292292
...
293293
```
294294
295+
## Enable standalone feature
296+
297+
When your application size exceeds 250Mb, the Next.js [Output File Tracing](https://nextjs.org/docs/advanced-features/output-file-tracing) feature helps optimize the app size and enhance performance.
298+
299+
Output File Tracing creates a compressed version of the whole application with necessary package dependencies built into a folder named *.next/standalone*. This folder is meant to deploy on its own without additional *node_modules* dependencies.
300+
301+
In order to enable the `standalone` feature, add the following additional property to your `next.config.js`:
302+
```js
303+
module.exports ={
304+
output:"standalone",
305+
}
306+
```
307+
308+
You will also need to configure the `build` command in the `package.json` file in order to copy static files to your standalone output.
309+
```json
310+
{
311+
...
312+
"scripts": {
313+
...
314+
"build": "next build && cp -r .next/static .next/standalone/.next/ && cp -r public .next/standalone/"
315+
...
316+
}
317+
...
318+
}
319+
```
320+
295321
## Enable logging for Next.js
296322
297323
Following best practices for Next.js server API troubleshooting, add logging to the API to catch these errors. Logging on Azure uses **Application Insights**. In order to preload this SDK, you need to create a custom start up script. To learn more:

0 commit comments

Comments
 (0)