2022-10-27 10:36:37 +00:00
|
|
|
import { defineUntypedSchema } from 'untyped'
|
2021-09-27 12:49:36 +00:00
|
|
|
import { join, resolve } from 'pathe'
|
2022-10-15 10:56:15 +00:00
|
|
|
import { isDebug, isDevelopment } from 'std-env'
|
2023-01-30 12:09:48 +00:00
|
|
|
import { defu } from 'defu'
|
2022-09-12 20:06:17 +00:00
|
|
|
import { findWorkspaceDir } from 'pkg-types'
|
2022-12-11 21:44:52 +00:00
|
|
|
import type { RuntimeConfig } from '../types/config'
|
2021-03-28 20:14:04 +00:00
|
|
|
|
2022-08-26 15:47:29 +00:00
|
|
|
export default defineUntypedSchema({
|
2022-01-31 21:13:58 +00:00
|
|
|
/**
|
2022-09-01 10:05:02 +00:00
|
|
|
* Extend project from multiple local or remote sources.
|
2022-01-31 21:13:58 +00:00
|
|
|
*
|
|
|
|
* Value should be either a string or array of strings pointing to source directories or config path relative to current config.
|
|
|
|
*
|
|
|
|
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
|
|
|
|
*
|
2022-04-07 12:57:57 +00:00
|
|
|
* @type {string|string[]}
|
2022-01-31 21:13:58 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
extends: null,
|
|
|
|
|
2022-09-01 10:05:02 +00:00
|
|
|
/**
|
|
|
|
* Extend project from a local or remote source.
|
|
|
|
*
|
|
|
|
* Value should be a string pointing to source directory or config path relative to current config.
|
|
|
|
*
|
|
|
|
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
|
|
|
|
*
|
|
|
|
* @type {string}
|
|
|
|
*
|
|
|
|
*/
|
2022-09-08 14:15:33 +00:00
|
|
|
theme: null,
|
2022-09-01 10:05:02 +00:00
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
2022-09-12 20:06:17 +00:00
|
|
|
* Define the root directory of your application.
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
|
|
|
* This property can be overwritten (for example, running `nuxt ./my-app/`
|
|
|
|
* will set the `rootDir` to the absolute path of `./my-app/` from the
|
|
|
|
* current/working directory.
|
|
|
|
*
|
|
|
|
* It is normally not needed to configure this option.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
rootDir: {
|
|
|
|
$resolve: val => typeof val === 'string' ? resolve(val) : process.cwd()
|
|
|
|
},
|
|
|
|
|
2022-09-12 20:06:17 +00:00
|
|
|
/**
|
|
|
|
* Define the workspace directory of your application.
|
|
|
|
*
|
|
|
|
* Often this is used when in a monorepo setup. Nuxt will attempt to detect
|
|
|
|
* your workspace directory automatically, but you can override it here.
|
|
|
|
*
|
|
|
|
* It is normally not needed to configure this option.
|
|
|
|
*/
|
|
|
|
workspaceDir: {
|
|
|
|
$resolve: async (val, get) => val ? resolve(await get('rootDir'), val) : await findWorkspaceDir(await get('rootDir')).catch(() => get('rootDir'))
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Define the source directory of your Nuxt application.
|
|
|
|
*
|
2022-08-11 21:25:35 +00:00
|
|
|
* If a relative path is specified, it will be relative to the `rootDir`.
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* export default {
|
2022-09-14 15:25:07 +00:00
|
|
|
* srcDir: 'src/'
|
2021-04-15 18:49:29 +00:00
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
* This would work with the following folder structure:
|
|
|
|
* ```bash
|
|
|
|
* -| app/
|
|
|
|
* ---| node_modules/
|
|
|
|
* ---| nuxt.config.js
|
|
|
|
* ---| package.json
|
2022-09-14 15:25:07 +00:00
|
|
|
* ---| src/
|
2021-04-15 18:49:29 +00:00
|
|
|
* ------| assets/
|
|
|
|
* ------| components/
|
|
|
|
* ------| layouts/
|
|
|
|
* ------| middleware/
|
|
|
|
* ------| pages/
|
|
|
|
* ------| plugins/
|
|
|
|
* ------| static/
|
|
|
|
* ------| store/
|
2022-09-14 15:25:07 +00:00
|
|
|
* ------| server/
|
2021-04-15 18:49:29 +00:00
|
|
|
* ```
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
srcDir: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => resolve(await get('rootDir'), val || '.')
|
2021-03-28 20:14:04 +00:00
|
|
|
},
|
|
|
|
|
2022-10-10 10:49:44 +00:00
|
|
|
/**
|
|
|
|
* Define the server directory of your Nuxt application, where Nitro
|
|
|
|
* routes, middleware and plugins are kept.
|
|
|
|
*
|
|
|
|
* If a relative path is specified, it will be relative to your `rootDir`.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
serverDir: {
|
|
|
|
$resolve: async (val, get) => resolve(await get('rootDir'), val || resolve(await get('srcDir'), 'server'))
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Define the directory where your built Nuxt files will be placed.
|
|
|
|
*
|
|
|
|
* Many tools assume that `.nuxt` is a hidden directory (because it starts
|
|
|
|
* with a `.`). If that is a problem, you can use this option to prevent that.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* export default {
|
|
|
|
* buildDir: 'nuxt-build'
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
buildDir: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => resolve(await get('rootDir'), val || '.nuxt')
|
2021-03-28 20:14:04 +00:00
|
|
|
},
|
|
|
|
|
2022-10-27 10:36:37 +00:00
|
|
|
/**
|
|
|
|
* Used to set the modules directories for path resolving (for example, webpack's
|
|
|
|
* `resolveLoading`, `nodeExternals` and `postcss`).
|
|
|
|
*
|
|
|
|
* The configuration path is relative to `options.rootDir` (default is current working directory).
|
|
|
|
*
|
|
|
|
* Setting this field may be necessary if your project is organized as a yarn workspace-styled mono-repository.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* export default {
|
|
|
|
* modulesDir: ['../../node_modules']
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
modulesDir: {
|
|
|
|
$default: ['node_modules'],
|
|
|
|
$resolve: async (val, get) => [
|
|
|
|
...await Promise.all(val.map(async (dir: string) => resolve(await get('rootDir'), dir))),
|
|
|
|
resolve(process.cwd(), 'node_modules')
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Whether Nuxt is running in development mode.
|
|
|
|
*
|
2022-08-11 21:25:35 +00:00
|
|
|
* Normally, you should not need to set this.
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-11-03 14:39:38 +00:00
|
|
|
dev: Boolean(isDevelopment),
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-11 21:25:35 +00:00
|
|
|
* Whether your app is being unit tested.
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-11-03 14:39:38 +00:00
|
|
|
test: Boolean(isDevelopment),
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-11 21:25:35 +00:00
|
|
|
* Set to `true` to enable debug mode.
|
2021-08-11 21:48:33 +00:00
|
|
|
*
|
2022-10-15 10:56:15 +00:00
|
|
|
* At the moment, it prints out hook names and timings on the server, and
|
|
|
|
* logs hook arguments as well in the browser.
|
|
|
|
*
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
|
|
|
debug: {
|
2022-10-15 10:56:15 +00:00
|
|
|
$resolve: async (val, get) => val ?? isDebug
|
2021-04-15 18:49:29 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to enable rendering of HTML - either dynamically (in server mode) or at generate time.
|
2023-02-15 12:54:49 +00:00
|
|
|
* If set to `false` generated pages will have no content.
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2022-09-08 14:15:33 +00:00
|
|
|
ssr: {
|
|
|
|
$resolve: (val) => val ?? true,
|
|
|
|
},
|
2021-03-28 20:14:04 +00:00
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
2022-08-11 21:25:35 +00:00
|
|
|
* Modules are Nuxt extensions which can extend its core functionality and add endless integrations.
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
|
|
|
* Each module is either a string (which can refer to a package, or be a path to a file), a
|
|
|
|
* tuple with the module as first string and the options as a second object, or an inline module function.
|
|
|
|
*
|
|
|
|
* Nuxt tries to resolve each item in the modules array using node require path
|
|
|
|
* (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used.
|
|
|
|
*
|
2021-08-11 21:48:33 +00:00
|
|
|
* @note Modules are executed sequentially so the order is important.
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* modules: [
|
|
|
|
* // Using package name
|
|
|
|
* '@nuxtjs/axios',
|
|
|
|
* // Relative to your project srcDir
|
|
|
|
* '~/modules/awesome.js',
|
|
|
|
* // Providing options
|
|
|
|
* ['@nuxtjs/google-analytics', { ua: 'X1234567' }],
|
|
|
|
* // Inline definition
|
|
|
|
* function () {}
|
|
|
|
* ]
|
|
|
|
* ```
|
2022-01-21 11:47:13 +00:00
|
|
|
* @type {(typeof import('../src/types/module').NuxtModule | string | [typeof import('../src/types/module').NuxtModule | string, Record<string, any>])[]}
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
modules: [],
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-11 21:25:35 +00:00
|
|
|
* Customize default directory structure used by Nuxt.
|
2021-08-11 21:48:33 +00:00
|
|
|
*
|
2021-04-15 18:49:29 +00:00
|
|
|
* It is better to stick with defaults unless needed.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
dir: {
|
2021-08-11 21:48:33 +00:00
|
|
|
/**
|
2022-08-11 21:25:35 +00:00
|
|
|
* The assets directory (aliased as `~assets` in your build).
|
2021-08-11 21:48:33 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
assets: 'assets',
|
2022-10-27 10:36:37 +00:00
|
|
|
|
2021-08-11 21:48:33 +00:00
|
|
|
/**
|
|
|
|
* The layouts directory, each file of which will be auto-registered as a Nuxt layout.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
layouts: 'layouts',
|
2022-10-27 10:36:37 +00:00
|
|
|
|
2021-08-11 21:48:33 +00:00
|
|
|
/**
|
|
|
|
* The middleware directory, each file of which will be auto-registered as a Nuxt middleware.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
middleware: 'middleware',
|
2022-10-27 10:36:37 +00:00
|
|
|
|
2023-03-03 17:52:55 +00:00
|
|
|
/**
|
|
|
|
* The modules directory, each file in which will be auto-registered as a Nuxt module.
|
|
|
|
*/
|
|
|
|
modules: 'modules',
|
|
|
|
|
2021-08-11 21:48:33 +00:00
|
|
|
/**
|
|
|
|
* The directory which will be processed to auto-generate your application page routes.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
pages: 'pages',
|
2022-10-27 10:36:37 +00:00
|
|
|
|
2022-10-07 07:13:12 +00:00
|
|
|
/**
|
|
|
|
* The plugins directory, each file of which will be auto-registered as a Nuxt plugin.
|
|
|
|
*/
|
|
|
|
plugins: 'plugins',
|
2022-10-27 10:36:37 +00:00
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
2021-06-30 10:29:48 +00:00
|
|
|
* The directory containing your static files, which will be directly accessible via the Nuxt server
|
|
|
|
* and copied across into your `dist` folder when your app is generated.
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-06-30 10:29:48 +00:00
|
|
|
public: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => val || await get('dir.static') || 'public',
|
2021-06-30 10:29:48 +00:00
|
|
|
},
|
2022-10-27 10:36:37 +00:00
|
|
|
|
2021-06-30 10:29:48 +00:00
|
|
|
static: {
|
|
|
|
$schema: { deprecated: 'use `dir.public` option instead' },
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => val || await get('dir.public') || 'public',
|
2022-10-27 10:36:37 +00:00
|
|
|
}
|
2021-03-28 20:14:04 +00:00
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* The extensions that should be resolved by the Nuxt resolver.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
extensions: {
|
2021-11-02 15:27:42 +00:00
|
|
|
$resolve: val => ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.vue'].concat(val).filter(Boolean)
|
2021-03-28 20:14:04 +00:00
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* You can improve your DX by defining additional aliases to access custom directories
|
|
|
|
* within your JavaScript and CSS.
|
|
|
|
*
|
2021-08-11 21:48:33 +00:00
|
|
|
* @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access
|
2021-04-15 18:49:29 +00:00
|
|
|
* your alias by prefixing it with `~`.
|
|
|
|
*
|
2022-02-09 21:27:35 +00:00
|
|
|
* @note These aliases will be automatically added to the generated `.nuxt/tsconfig.json` so you can get full
|
|
|
|
* type support and path auto-complete. In case you need to extend options provided by `./.nuxt/tsconfig.json`
|
|
|
|
* further, make sure to add them here or within the `typescript.tsConfig` property in `nuxt.config`.
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* export default {
|
|
|
|
* alias: {
|
2022-05-18 06:15:38 +00:00
|
|
|
* 'images': fileURLToPath(new URL('./assets/images', import.meta.url)),
|
|
|
|
* 'style': fileURLToPath(new URL('./assets/style', import.meta.url)),
|
|
|
|
* 'data': fileURLToPath(new URL('./assets/other/data', import.meta.url))
|
2021-04-15 18:49:29 +00:00
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* ```html
|
|
|
|
* <template>
|
|
|
|
* <img src="~images/main-bg.jpg">
|
|
|
|
* </template>
|
|
|
|
*
|
|
|
|
* <script>
|
|
|
|
* import data from 'data/test.json'
|
|
|
|
* </script>
|
|
|
|
*
|
|
|
|
* <style>
|
|
|
|
* // Uncomment the below
|
|
|
|
* //@import '~style/variables.scss';
|
|
|
|
* //@import '~style/utils.scss';
|
|
|
|
* //@import '~style/base.scss';
|
|
|
|
* body {
|
|
|
|
* background-image: url('~images/main-bg.jpg');
|
|
|
|
* }
|
|
|
|
* </style>
|
|
|
|
* ```
|
2021-08-11 21:48:33 +00:00
|
|
|
*
|
2021-11-19 12:22:27 +00:00
|
|
|
* @type {Record<string, string>}
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
alias: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => ({
|
|
|
|
'~~': await get('rootDir'),
|
|
|
|
'@@': await get('rootDir'),
|
|
|
|
'~': await get('srcDir'),
|
|
|
|
'@': await get('srcDir'),
|
|
|
|
[await get('dir.assets')]: join(await get('srcDir'), await get('dir.assets')),
|
|
|
|
[await get('dir.public')]: join(await get('srcDir'), await get('dir.public')),
|
2021-03-28 20:14:04 +00:00
|
|
|
...val
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Pass options directly to `node-ignore` (which is used by Nuxt to ignore files).
|
|
|
|
*
|
|
|
|
* @see [node-ignore](https://github.com/kaelzhang/node-ignore)
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* ignoreOptions: {
|
|
|
|
* ignorecase: false
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
ignoreOptions: undefined,
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Any file in `pages/`, `layouts/`, `middleware/` or `store/` will be ignored during
|
|
|
|
* building if its filename starts with the prefix specified by `ignorePrefix`.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
ignorePrefix: '-',
|
2021-04-15 18:49:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* More customizable than `ignorePrefix`: all files matching glob patterns specified
|
|
|
|
* inside the `ignore` array will be ignored in building.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
ignore: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => [
|
2022-02-28 16:11:46 +00:00
|
|
|
'**/*.stories.{js,ts,jsx,tsx}', // ignore storybook files
|
|
|
|
'**/*.{spec,test}.{js,ts,jsx,tsx}', // ignore tests
|
2022-11-09 09:01:09 +00:00
|
|
|
'**/*.d.ts', // ignore type declarations
|
2022-02-28 16:11:46 +00:00
|
|
|
'.output',
|
2022-09-12 18:22:41 +00:00
|
|
|
await get('ignorePrefix') && `**/${await get('ignorePrefix')}*.*`
|
2021-03-28 20:14:04 +00:00
|
|
|
].concat(val).filter(Boolean)
|
|
|
|
},
|
|
|
|
|
2023-03-09 11:46:08 +00:00
|
|
|
/**
|
|
|
|
* The watch property lets you define patterns that will restart the Nuxt dev server when changed.
|
|
|
|
*
|
|
|
|
* It is an array of strings or regular expressions, which will be matched against the file path
|
|
|
|
* relative to the project `srcDir`.
|
|
|
|
*
|
|
|
|
* @type {Array<string | RegExp>}
|
|
|
|
*/
|
|
|
|
watch: {
|
|
|
|
$resolve: val => [].concat(val).filter((b: unknown) => typeof b === 'string' || b instanceof RegExp),
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* The watchers property lets you overwrite watchers configuration in your `nuxt.config`.
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
watchers: {
|
2021-04-15 18:49:29 +00:00
|
|
|
/** An array of event types, which, when received, will cause the watcher to restart. */
|
2021-03-28 20:14:04 +00:00
|
|
|
rewatchOnRawEvents: undefined,
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* `watchOptions` to pass directly to webpack.
|
|
|
|
*
|
|
|
|
* @see [webpack@4 watch options](https://v4.webpack.js.org/configuration/watch/#watchoptions).
|
|
|
|
* */
|
2021-03-28 20:14:04 +00:00
|
|
|
webpack: {
|
|
|
|
aggregateTimeout: 1000
|
|
|
|
},
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Options to pass directly to `chokidar`.
|
|
|
|
*
|
|
|
|
* @see [chokidar](https://github.com/paulmillr/chokidar#api)
|
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
chokidar: {
|
|
|
|
ignoreInitial: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
2021-08-11 21:48:33 +00:00
|
|
|
* Hooks are listeners to Nuxt events that are typically used in modules,
|
|
|
|
* but are also available in `nuxt.config`.
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
|
|
|
* Internally, hooks follow a naming pattern using colons (e.g., build:done).
|
|
|
|
*
|
2021-08-11 21:48:33 +00:00
|
|
|
* For ease of configuration, you can also structure them as an hierarchical
|
|
|
|
* object in `nuxt.config` (as below).
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
|
|
|
* @example
|
2022-04-15 15:19:05 +00:00
|
|
|
* ```js'node:fs'
|
|
|
|
* import fs from 'node:fs'
|
|
|
|
* import path from 'node:path'
|
2021-04-15 18:49:29 +00:00
|
|
|
* export default {
|
|
|
|
* hooks: {
|
|
|
|
* build: {
|
|
|
|
* done(builder) {
|
|
|
|
* const extraFilePath = path.join(
|
|
|
|
* builder.nuxt.options.buildDir,
|
|
|
|
* 'extra-file'
|
|
|
|
* )
|
|
|
|
* fs.writeFileSync(extraFilePath, 'Something extra')
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
2021-11-19 12:22:27 +00:00
|
|
|
* @type {typeof import('../src/types/hooks').NuxtHooks}
|
2021-04-15 18:49:29 +00:00
|
|
|
*/
|
2021-03-28 20:14:04 +00:00
|
|
|
hooks: null,
|
|
|
|
|
2021-04-15 18:49:29 +00:00
|
|
|
/**
|
|
|
|
* Runtime config allows passing dynamic config and environment variables to the Nuxt app context.
|
2022-02-08 19:09:44 +00:00
|
|
|
*
|
2022-04-11 14:34:23 +00:00
|
|
|
* The value of this object is accessible from server only using `useRuntimeConfig`.
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
2022-04-11 14:34:23 +00:00
|
|
|
* It mainly should hold _private_ configuration which is not exposed on the frontend.
|
2021-04-15 18:49:29 +00:00
|
|
|
* This could include a reference to your API secret tokens.
|
2022-02-08 19:09:44 +00:00
|
|
|
*
|
2022-04-11 14:34:23 +00:00
|
|
|
* Anything under `public` and `app` will be exposed to the frontend as well.
|
|
|
|
*
|
2022-02-07 10:20:53 +00:00
|
|
|
* Values are automatically replaced by matching env variables at runtime, e.g. setting an environment
|
2022-08-29 09:47:02 +00:00
|
|
|
* variable `NUXT_API_KEY=my-api-key NUXT_PUBLIC_BASE_URL=/foo/` would overwrite the two values in the example below.
|
2021-04-15 18:49:29 +00:00
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* export default {
|
2022-04-11 14:34:23 +00:00
|
|
|
* runtimeConfig: {
|
2022-05-18 06:16:24 +00:00
|
|
|
* apiKey: '' // Default to an empty string, automatically set at runtime using process.env.NUXT_API_KEY
|
2022-04-11 14:34:23 +00:00
|
|
|
* public: {
|
|
|
|
* baseURL: '' // Exposed to the frontend as well.
|
|
|
|
* }
|
2021-04-15 18:49:29 +00:00
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
2022-04-11 14:34:23 +00:00
|
|
|
* @type {typeof import('../src/types/config').RuntimeConfig}
|
|
|
|
*/
|
|
|
|
runtimeConfig: {
|
2023-01-28 15:18:04 +00:00
|
|
|
$resolve: async (val: RuntimeConfig, get) => {
|
|
|
|
provideFallbackValues(val)
|
|
|
|
return defu(val, {
|
|
|
|
public: {},
|
|
|
|
app: {
|
|
|
|
baseURL: (await get('app')).baseURL,
|
|
|
|
buildAssetsDir: (await get('app')).buildAssetsDir,
|
|
|
|
cdnURL: (await get('app')).cdnURL,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-04-11 14:34:23 +00:00
|
|
|
},
|
|
|
|
|
2022-08-17 15:23:13 +00:00
|
|
|
/**
|
|
|
|
* Additional app configuration
|
|
|
|
*
|
|
|
|
* For programmatic usage and type support, you can directly provide app config with this option.
|
|
|
|
* It will be merged with `app.config` file as default value.
|
|
|
|
*
|
|
|
|
* @type {typeof import('../src/types/config').AppConfig}
|
|
|
|
*/
|
2022-08-29 10:42:05 +00:00
|
|
|
appConfig: {},
|
2023-01-23 18:07:21 +00:00
|
|
|
|
|
|
|
$schema: {}
|
2022-08-26 15:47:29 +00:00
|
|
|
})
|
2023-01-28 15:18:04 +00:00
|
|
|
|
|
|
|
function provideFallbackValues (obj: Record<string, any>) {
|
|
|
|
for (const key in obj) {
|
|
|
|
if (typeof obj[key] === 'undefined' || obj[key] === null) {
|
|
|
|
obj[key] = ''
|
|
|
|
} else if (typeof obj[key] === 'object') {
|
|
|
|
provideFallbackValues(obj[key])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|