2021-06-14 12:31:30 +00:00
|
|
|
# Custom build preset (advanced)
|
|
|
|
|
2021-10-11 17:18:38 +00:00
|
|
|
Get full control of Nuxt Nitro output to deploy on any kind of hosting platform.
|
2021-06-14 12:31:30 +00:00
|
|
|
|
2021-10-11 17:18:38 +00:00
|
|
|
::list{type=info}
|
2021-10-29 11:26:01 +00:00
|
|
|
|
2021-10-11 17:18:38 +00:00
|
|
|
- Allows full customization
|
|
|
|
- This is an advanced usage pattern
|
|
|
|
::
|
|
|
|
|
|
|
|
::alert{icon=IconPresets}
|
2022-04-06 05:56:08 +00:00
|
|
|
Back to [presets list](/guide/deployment/presets).
|
2021-10-11 17:18:38 +00:00
|
|
|
::
|
|
|
|
|
|
|
|
## Setup
|
2021-06-14 12:31:30 +00:00
|
|
|
|
2022-04-14 13:38:47 +00:00
|
|
|
You can create your own custom-built preset. See [the provided presets](https://github.com/unjs/nitro/tree/main/src/presets) for examples.
|
2021-06-14 12:31:30 +00:00
|
|
|
|
2021-10-11 17:18:38 +00:00
|
|
|
### Inline preset definition
|
2021-06-14 12:31:30 +00:00
|
|
|
|
|
|
|
You can define everything that a custom preset would configure directly in the Nitro options:
|
|
|
|
|
2021-10-13 08:58:28 +00:00
|
|
|
```ts [nuxt.config.js|ts]
|
2021-06-14 12:31:30 +00:00
|
|
|
export default {
|
|
|
|
nitro: {
|
2021-10-11 17:18:38 +00:00
|
|
|
// preset options
|
2021-06-14 12:31:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-11 17:18:38 +00:00
|
|
|
### Reusable preset
|
2021-06-14 12:31:30 +00:00
|
|
|
|
|
|
|
You can also define a preset in a separate file (or publish as a separate npm package).
|
|
|
|
|
|
|
|
```ts [my-preset/index.ts]
|
2022-04-07 11:28:04 +00:00
|
|
|
import type { NitroPreset } from 'nitropack'
|
2021-06-14 12:31:30 +00:00
|
|
|
|
|
|
|
const myPreset: NitroPreset = {
|
|
|
|
// Your custom configuration
|
|
|
|
}
|
|
|
|
|
|
|
|
export default myPreset
|
|
|
|
```
|
|
|
|
|
|
|
|
Then in your `nuxt.config` you can specify that Nitro should use your custom preset:
|
|
|
|
|
2021-10-13 08:58:28 +00:00
|
|
|
```ts [nuxt.config.js|ts]
|
2021-06-14 12:31:30 +00:00
|
|
|
import { resolve } from 'path'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
nitro: {
|
|
|
|
preset: resolve(__dirname, 'my-preset')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|