mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
chore(schema): enable linting (#22546)
This commit is contained in:
parent
5d86580f62
commit
5244555880
@ -1,5 +1,5 @@
|
||||
dist
|
||||
node_modules
|
||||
schema
|
||||
packages/schema/schema
|
||||
**/*.tmpl.*
|
||||
sw.js
|
||||
|
15
.eslintrc
15
.eslintrc
@ -100,6 +100,21 @@
|
||||
"definedTags": ["__NO_SIDE_EFFECTS__"]
|
||||
}]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["packages/schema/**"],
|
||||
"rules": {
|
||||
"jsdoc/no-undefined-types": "off",
|
||||
"jsdoc/valid-types": "off",
|
||||
"jsdoc/check-tag-names": [
|
||||
"error",
|
||||
{
|
||||
"definedTags": ["experimental"]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"jsdoc": {
|
||||
"ignoreInternal": true,
|
||||
|
@ -34,6 +34,7 @@ export default defineUntypedSchema({
|
||||
/**
|
||||
* An array of custom directories that will be auto-imported.
|
||||
* Note that this option will not override the default directories (~/composables, ~/utils).
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* imports: {
|
||||
@ -57,9 +58,8 @@ export default defineUntypedSchema({
|
||||
* Manually disable nuxt telemetry.
|
||||
*
|
||||
* @see [Nuxt Telemetry](https://github.com/nuxt/telemetry) for more information.
|
||||
*
|
||||
* @type {boolean | Record<string, any>}
|
||||
*/
|
||||
*/
|
||||
telemetry: undefined,
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@ export default defineUntypedSchema({
|
||||
vue: {
|
||||
/**
|
||||
* Options for the Vue compiler that will be passed at build time.
|
||||
*
|
||||
* @see [documentation](https://vuejs.org/api/application.html#app-config-compileroptions)
|
||||
* @type {typeof import('@vue/compiler-core').CompilerOptions}
|
||||
*/
|
||||
@ -19,11 +20,12 @@ export default defineUntypedSchema({
|
||||
* Include Vue compiler in runtime bundle.
|
||||
*/
|
||||
runtimeCompiler: {
|
||||
$resolve: async (val, get) => val ?? await get('experimental.runtimeVueCompiler') ?? false,
|
||||
$resolve: async (val, get) => val ?? await get('experimental.runtimeVueCompiler') ?? false
|
||||
},
|
||||
|
||||
/**
|
||||
* Vue Experimental: Enable reactive destructure for `defineProps`
|
||||
*
|
||||
* @see [Vue RFC#502](https://github.com/vuejs/rfcs/discussions/502)
|
||||
* @type {boolean}
|
||||
*/
|
||||
@ -31,6 +33,7 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* Vue Experimental: Enable macro `defineModel`
|
||||
*
|
||||
* @see [Vue RFC#503](https://github.com/vuejs/rfcs/discussions/503)
|
||||
* @type {boolean}
|
||||
*/
|
||||
@ -45,24 +48,26 @@ export default defineUntypedSchema({
|
||||
* The base path of your Nuxt application.
|
||||
*
|
||||
* This can be set at runtime by setting the NUXT_APP_BASE_URL environment variable.
|
||||
*
|
||||
* @example
|
||||
* ```bash
|
||||
* NUXT_APP_BASE_URL=/prefix/ node .output/server/index.mjs
|
||||
* ```
|
||||
*/
|
||||
baseURL: {
|
||||
$resolve: async (val) => val || process.env.NUXT_APP_BASE_URL || '/',
|
||||
$resolve: val => val || process.env.NUXT_APP_BASE_URL || '/'
|
||||
},
|
||||
|
||||
/** The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). This is set at build time and should not be customized at runtime. */
|
||||
buildAssetsDir: {
|
||||
$resolve: async (val) => val || process.env.NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/',
|
||||
$resolve: val => val || process.env.NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/'
|
||||
},
|
||||
|
||||
/**
|
||||
* An absolute URL to serve the public folder from (production-only).
|
||||
*
|
||||
* This can be set to a different value at runtime by setting the `NUXT_APP_CDN_URL` environment variable.
|
||||
*
|
||||
* @example
|
||||
* ```bash
|
||||
* NUXT_APP_CDN_URL=https://mycdn.org/ node .output/server/index.mjs
|
||||
@ -175,10 +180,11 @@ export default defineUntypedSchema({
|
||||
* Customize Nuxt root element tag.
|
||||
*
|
||||
*/
|
||||
rootTag: 'div',
|
||||
rootTag: 'div'
|
||||
},
|
||||
|
||||
/** A path to an HTML file, the contents of which will be inserted into any HTML page
|
||||
/**
|
||||
* A path to an HTML file, the contents of which will be inserted into any HTML page
|
||||
* rendered with `ssr: false`.
|
||||
*
|
||||
* By default Nuxt will look in `~/app/spa-loading-template.html` for this file.
|
||||
@ -230,7 +236,6 @@ export default defineUntypedSchema({
|
||||
* }
|
||||
* </style>
|
||||
* ```
|
||||
*
|
||||
* @type {string | false}
|
||||
*/
|
||||
spaLoadingTemplate: {
|
||||
@ -249,9 +254,7 @@ export default defineUntypedSchema({
|
||||
* @note Plugins are also auto-registered from the `~/plugins` directory
|
||||
* and these plugins do not need to be listed in `nuxt.config` unless you
|
||||
* need to customize their order. All plugins are deduplicated by their src path.
|
||||
*
|
||||
* @see https://nuxt.com/docs/guide/directory-structure/plugins
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* plugins: [
|
||||
|
@ -16,7 +16,7 @@ export default defineUntypedSchema({
|
||||
}
|
||||
const map: Record<string, string> = {
|
||||
vite: '@nuxt/vite-builder',
|
||||
webpack: '@nuxt/webpack-builder',
|
||||
webpack: '@nuxt/webpack-builder'
|
||||
}
|
||||
return map[val] || val || (await get('vite') === false ? map.webpack : map.vite)
|
||||
}
|
||||
@ -36,7 +36,7 @@ export default defineUntypedSchema({
|
||||
server: true,
|
||||
client: await get('dev')
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -96,7 +96,6 @@ export default defineUntypedSchema({
|
||||
* }
|
||||
* ]
|
||||
* ```
|
||||
*
|
||||
* @type {typeof import('../src/types/nuxt').NuxtTemplate<any>[]}
|
||||
*/
|
||||
templates: [],
|
||||
@ -113,7 +112,6 @@ export default defineUntypedSchema({
|
||||
* }
|
||||
* ```
|
||||
* @type {boolean | typeof import('webpack-bundle-analyzer').BundleAnalyzerPlugin.Options | typeof import('rollup-plugin-visualizer').PluginVisualizerOptions}
|
||||
*
|
||||
*/
|
||||
analyze: {
|
||||
$resolve: async (val, get) => {
|
||||
@ -128,7 +126,7 @@ export default defineUntypedSchema({
|
||||
filename: join(analyzeDir, '{name}.html')
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -147,13 +145,13 @@ export default defineUntypedSchema({
|
||||
* @type {Array<{ name: string, source?: string | RegExp, argumentLength: number }>}
|
||||
*/
|
||||
keyedComposables: {
|
||||
$resolve: (val) => [
|
||||
$resolve: val => [
|
||||
{ name: 'defineNuxtComponent', argumentLength: 2 },
|
||||
{ name: 'useState', argumentLength: 2 },
|
||||
{ name: 'useFetch', argumentLength: 3 },
|
||||
{ name: 'useAsyncData', argumentLength: 3 },
|
||||
{ name: 'useLazyAsyncData', argumentLength: 3 },
|
||||
{ name: 'useLazyFetch', argumentLength: 3 },
|
||||
{ name: 'useLazyFetch', argumentLength: 3 }
|
||||
].concat(val).filter(Boolean)
|
||||
},
|
||||
|
||||
@ -172,18 +170,22 @@ export default defineUntypedSchema({
|
||||
composables: {
|
||||
server: {
|
||||
$resolve: async (val, get) => defu(val || {},
|
||||
await get('dev') ? {} : {
|
||||
vue: ['onBeforeMount', 'onMounted', 'onBeforeUpdate', 'onRenderTracked', 'onRenderTriggered', 'onActivated', 'onDeactivated', 'onBeforeUnmount'],
|
||||
'#app': ['definePayloadReviver', 'definePageMeta']
|
||||
}
|
||||
await get('dev')
|
||||
? {}
|
||||
: {
|
||||
vue: ['onBeforeMount', 'onMounted', 'onBeforeUpdate', 'onRenderTracked', 'onRenderTriggered', 'onActivated', 'onDeactivated', 'onBeforeUnmount'],
|
||||
'#app': ['definePayloadReviver', 'definePageMeta']
|
||||
}
|
||||
)
|
||||
},
|
||||
client: {
|
||||
$resolve: async (val, get) => defu(val || {},
|
||||
await get('dev') ? {} : {
|
||||
vue: ['onServerPrefetch', 'onRenderTracked', 'onRenderTriggered'],
|
||||
'#app': ['definePayloadReducer', 'definePageMeta']
|
||||
}
|
||||
await get('dev')
|
||||
? {}
|
||||
: {
|
||||
vue: ['onServerPrefetch', 'onRenderTracked', 'onRenderTriggered'],
|
||||
'#app': ['definePayloadReducer', 'definePageMeta']
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ export default defineUntypedSchema({
|
||||
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
|
||||
*
|
||||
* @type {string|string[]}
|
||||
*
|
||||
*/
|
||||
extends: null,
|
||||
|
||||
@ -26,7 +25,6 @@ export default defineUntypedSchema({
|
||||
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
|
||||
*
|
||||
* @type {string}
|
||||
*
|
||||
*/
|
||||
theme: null,
|
||||
|
||||
@ -170,7 +168,7 @@ export default defineUntypedSchema({
|
||||
*
|
||||
*/
|
||||
debug: {
|
||||
$resolve: async (val, get) => val ?? isDebug
|
||||
$resolve: val => val ?? isDebug
|
||||
},
|
||||
|
||||
/**
|
||||
@ -178,7 +176,7 @@ export default defineUntypedSchema({
|
||||
* If set to `false` generated pages will have no content.
|
||||
*/
|
||||
ssr: {
|
||||
$resolve: (val) => val ?? true,
|
||||
$resolve: val => val ?? true
|
||||
},
|
||||
|
||||
/**
|
||||
@ -191,7 +189,6 @@ export default defineUntypedSchema({
|
||||
* (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used.
|
||||
*
|
||||
* @note Modules are executed sequentially so the order is important.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* modules: [
|
||||
@ -252,12 +249,12 @@ export default defineUntypedSchema({
|
||||
* and copied across into your `dist` folder when your app is generated.
|
||||
*/
|
||||
public: {
|
||||
$resolve: async (val, get) => val || await get('dir.static') || 'public',
|
||||
$resolve: async (val, get) => val || await get('dir.static') || 'public'
|
||||
},
|
||||
|
||||
static: {
|
||||
$schema: { deprecated: 'use `dir.public` option instead' },
|
||||
$resolve: async (val, get) => val || await get('dir.public') || 'public',
|
||||
$resolve: async (val, get) => val || await get('dir.public') || 'public'
|
||||
}
|
||||
},
|
||||
|
||||
@ -274,11 +271,9 @@ export default defineUntypedSchema({
|
||||
*
|
||||
* @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access
|
||||
* your alias by prefixing it with `~`.
|
||||
*
|
||||
* @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`.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* export default {
|
||||
@ -309,7 +304,6 @@ export default defineUntypedSchema({
|
||||
* }
|
||||
* </style>
|
||||
* ```
|
||||
*
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
alias: {
|
||||
@ -328,7 +322,6 @@ export default defineUntypedSchema({
|
||||
* 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: {
|
||||
@ -343,7 +336,7 @@ export default defineUntypedSchema({
|
||||
* building if its filename starts with the prefix specified by `ignorePrefix`.
|
||||
*/
|
||||
ignorePrefix: {
|
||||
$resolve: (val) => val ?? '-',
|
||||
$resolve: val => val ?? '-'
|
||||
},
|
||||
|
||||
/**
|
||||
@ -372,7 +365,7 @@ export default defineUntypedSchema({
|
||||
* @type {Array<string | RegExp>}
|
||||
*/
|
||||
watch: {
|
||||
$resolve: val => [].concat(val).filter((b: unknown) => typeof b === 'string' || b instanceof RegExp),
|
||||
$resolve: val => [].concat(val).filter((b: unknown) => typeof b === 'string' || b instanceof RegExp)
|
||||
},
|
||||
|
||||
/**
|
||||
@ -385,7 +378,7 @@ export default defineUntypedSchema({
|
||||
* `watchOptions` to pass directly to webpack.
|
||||
*
|
||||
* @see [webpack@4 watch options](https://v4.webpack.js.org/configuration/watch/#watchoptions).
|
||||
* */
|
||||
*/
|
||||
webpack: {
|
||||
aggregateTimeout: 1000
|
||||
},
|
||||
@ -464,7 +457,7 @@ export default defineUntypedSchema({
|
||||
app: {
|
||||
baseURL: (await get('app')).baseURL,
|
||||
buildAssetsDir: (await get('app')).buildAssetsDir,
|
||||
cdnURL: (await get('app')).cdnURL,
|
||||
cdnURL: (await get('app')).cdnURL
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -17,10 +17,7 @@ export default defineUntypedSchema({
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* @type {boolean | { key: string; cert: string }}
|
||||
*
|
||||
*/
|
||||
https: false,
|
||||
|
||||
@ -43,6 +40,6 @@ export default defineUntypedSchema({
|
||||
*
|
||||
* @type {(data: { loading?: string }) => string}
|
||||
*/
|
||||
loadingTemplate: loadingTemplate
|
||||
loadingTemplate
|
||||
}
|
||||
})
|
||||
|
@ -6,11 +6,12 @@ export default defineUntypedSchema({
|
||||
* Set to true to generate an async entry point for the Vue bundle (for module federation support).
|
||||
*/
|
||||
asyncEntry: {
|
||||
$resolve: (val) => val ?? false
|
||||
$resolve: val => val ?? false
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable Vue's reactivity transform
|
||||
*
|
||||
* @see https://vuejs.org/guide/extras/reactivity-transform.html
|
||||
*
|
||||
* Warning: Reactivity transform feature has been marked as deprecated in Vue 3.3 and is planned to be
|
||||
@ -23,12 +24,14 @@ export default defineUntypedSchema({
|
||||
// https://github.com/unjs/nitro/issues/1118
|
||||
/**
|
||||
* Externalize `vue`, `@vue/*` and `vue-router` when building.
|
||||
*
|
||||
* @see https://github.com/nuxt/nuxt/issues/13632
|
||||
*/
|
||||
externalVue: true,
|
||||
|
||||
/**
|
||||
* Tree shakes contents of client-only components from server bundle.
|
||||
*
|
||||
* @see https://github.com/nuxt/framework/pull/5750
|
||||
*/
|
||||
treeshakeClientOnly: true,
|
||||
@ -47,7 +50,7 @@ export default defineUntypedSchema({
|
||||
* @type {false | 'manual' | 'automatic'}
|
||||
*/
|
||||
emitRouteChunkError: {
|
||||
$resolve: val => {
|
||||
$resolve: (val) => {
|
||||
if (val === true) {
|
||||
return 'manual'
|
||||
}
|
||||
@ -55,7 +58,7 @@ export default defineUntypedSchema({
|
||||
return 'automatic'
|
||||
}
|
||||
return val ?? 'automatic'
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -113,7 +116,7 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* Disable vue server renderer endpoint within nitro.
|
||||
*/
|
||||
*/
|
||||
noVueServer: false,
|
||||
|
||||
/**
|
||||
@ -148,6 +151,7 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* Experimental component islands support with <NuxtIsland> and .island.vue files.
|
||||
*
|
||||
* @type {true | 'local' | 'local+remote' | false}
|
||||
*/
|
||||
componentIslands: {
|
||||
|
@ -14,14 +14,13 @@ export default defineUntypedSchema({
|
||||
* ```js
|
||||
* routes: ['/users/1', '/users/2', '/users/3']
|
||||
* ```
|
||||
*
|
||||
* @type {string | string[]}
|
||||
*/
|
||||
routes: [],
|
||||
|
||||
/**
|
||||
* This option is no longer used. Instead, use `nitro.prerender.ignore`.
|
||||
*
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
exclude: []
|
||||
|
@ -5,7 +5,6 @@ export default defineUntypedSchema({
|
||||
* Configuration for Nitro.
|
||||
*
|
||||
* @see https://nitro.unjs.io/config/
|
||||
*
|
||||
* @type {typeof import('nitropack')['NitroConfig']}
|
||||
*/
|
||||
nitro: {
|
||||
@ -21,9 +20,7 @@ export default defineUntypedSchema({
|
||||
* Global route options applied to matching server routes.
|
||||
*
|
||||
* @experimental This is an experimental feature and API may change in the future.
|
||||
*
|
||||
* @see https://nitro.unjs.io/config/#routerules
|
||||
*
|
||||
* @type {typeof import('nitropack')['NitroConfig']['routeRules']}
|
||||
*/
|
||||
routeRules: {},
|
||||
@ -39,16 +36,13 @@ export default defineUntypedSchema({
|
||||
* - lazy: Specifies whether to use lazy loading to import the handler.
|
||||
*
|
||||
* @see https://nuxt.com/docs/guide/directory-structure/server
|
||||
*
|
||||
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* serverHandlers: [
|
||||
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
|
||||
* ]
|
||||
* ```
|
||||
*
|
||||
* @type {typeof import('nitropack')['NitroEventHandler'][]}
|
||||
*/
|
||||
serverHandlers: [],
|
||||
@ -57,7 +51,6 @@ export default defineUntypedSchema({
|
||||
* Nitro development-only server handlers.
|
||||
*
|
||||
* @see https://nitro.unjs.io/guide/routing
|
||||
*
|
||||
* @type {typeof import('nitropack')['NitroDevEventHandler'][]}
|
||||
*/
|
||||
devServerHandlers: []
|
||||
|
@ -8,6 +8,7 @@ export default defineUntypedSchema({
|
||||
* Options for configuring PostCSS plugins.
|
||||
*
|
||||
* https://postcss.org/
|
||||
*
|
||||
* @type {Record<string, any>}
|
||||
*/
|
||||
plugins: {
|
||||
@ -15,16 +16,18 @@ export default defineUntypedSchema({
|
||||
* https://github.com/postcss/postcss-import
|
||||
*/
|
||||
'postcss-import': {
|
||||
$resolve: async (val, get) => val !== false ? defu(val || {}, {
|
||||
resolve: createResolver({
|
||||
alias: { ...(await get('alias')) },
|
||||
modules: [
|
||||
await get('srcDir'),
|
||||
await get('rootDir'),
|
||||
...(await get('modulesDir'))
|
||||
]
|
||||
$resolve: async (val, get) => val !== false
|
||||
? defu(val || {}, {
|
||||
resolve: createResolver({
|
||||
alias: { ...(await get('alias')) },
|
||||
modules: [
|
||||
await get('srcDir'),
|
||||
await get('rootDir'),
|
||||
...(await get('modulesDir'))
|
||||
]
|
||||
})
|
||||
})
|
||||
}) : val,
|
||||
: val
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,6 @@ export default defineUntypedSchema({
|
||||
*
|
||||
* @see [documentation](https://router.vuejs.org/api/interfaces/routeroptions.html).
|
||||
* @type {typeof import('../src/types/router').RouterConfigSerializable}
|
||||
*
|
||||
*/
|
||||
options: {}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ export default defineUntypedSchema({
|
||||
* @type {'vite' | 'webpack' | 'shared' | false | undefined}
|
||||
*/
|
||||
builder: {
|
||||
$resolve: async (val, get) => val ?? null
|
||||
$resolve: val => val ?? null
|
||||
},
|
||||
|
||||
/**
|
||||
@ -39,13 +39,13 @@ export default defineUntypedSchema({
|
||||
* Requires to install `typescript` and `vue-tsc` as dev dependencies.
|
||||
*
|
||||
* @see https://nuxt.com/docs/guide/concepts/typescript
|
||||
*
|
||||
* @type {boolean | 'build'}
|
||||
*/
|
||||
typeCheck: false,
|
||||
|
||||
/**
|
||||
* You can extend generated `.nuxt/tsconfig.json` using this option.
|
||||
*
|
||||
* @type {typeof import('pkg-types')['TSConfig']}
|
||||
*/
|
||||
tsConfig: {},
|
||||
|
@ -48,11 +48,11 @@ export default defineUntypedSchema({
|
||||
},
|
||||
script: {
|
||||
propsDestructure: {
|
||||
$resolve: async (val, get) => val ?? Boolean((await get('vue')).propsDestructure),
|
||||
$resolve: async (val, get) => val ?? Boolean((await get('vue')).propsDestructure)
|
||||
},
|
||||
defineModel: {
|
||||
$resolve: async (val, get) => val ?? Boolean((await get('vue')).defineModel),
|
||||
},
|
||||
$resolve: async (val, get) => val ?? Boolean((await get('vue')).defineModel)
|
||||
}
|
||||
}
|
||||
},
|
||||
vueJsx: {
|
||||
|
@ -65,7 +65,6 @@ export default defineUntypedSchema({
|
||||
* Extracting into multiple CSS files is better for caching and preload isolation. It
|
||||
* can also improve page performance by downloading and resolving only those resources
|
||||
* that are needed.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* export default {
|
||||
@ -113,14 +112,12 @@ export default defineUntypedSchema({
|
||||
* as most browsers will cache the asset and not detect the changes on first load.
|
||||
*
|
||||
* This example changes fancy chunk names to numerical ids:
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* filenames: {
|
||||
* chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js')
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @type {
|
||||
* Record<
|
||||
* string,
|
||||
@ -140,8 +137,8 @@ export default defineUntypedSchema({
|
||||
* }
|
||||
*/
|
||||
filenames: {
|
||||
app: ({ isDev }: { isDev: boolean }) => isDev ? `[name].js` : `[contenthash:7].js`,
|
||||
chunk: ({ isDev }: { isDev: boolean }) => isDev ? `[name].js` : `[contenthash:7].js`,
|
||||
app: ({ isDev }: { isDev: boolean }) => isDev ? '[name].js' : '[contenthash:7].js',
|
||||
chunk: ({ isDev }: { isDev: boolean }) => isDev ? '[name].js' : '[contenthash:7].js',
|
||||
css: ({ isDev }: { isDev: boolean }) => isDev ? '[name].css' : 'css/[contenthash:7].css',
|
||||
img: ({ isDev }: { isDev: boolean }) => isDev ? '[path][name].[ext]' : 'img/[name].[contenthash:7].[ext]',
|
||||
font: ({ isDev }: { isDev: boolean }) => isDev ? '[path][name].[ext]' : 'fonts/[name].[contenthash:7].[ext]',
|
||||
@ -168,14 +165,15 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* See https://github.com/esbuild-kit/esbuild-loader
|
||||
*
|
||||
* @type {Omit<typeof import('esbuild-loader')['LoaderOptions'], 'loader'>}
|
||||
*/
|
||||
*/
|
||||
esbuild: {},
|
||||
|
||||
/**
|
||||
* See: https://github.com/webpack-contrib/file-loader#options
|
||||
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
|
||||
*
|
||||
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
|
||||
* @default
|
||||
* ```ts
|
||||
* { esModule: false }
|
||||
@ -185,8 +183,8 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* See: https://github.com/webpack-contrib/file-loader#options
|
||||
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
|
||||
*
|
||||
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
|
||||
* @default
|
||||
* ```ts
|
||||
* { esModule: false, limit: 1000 }
|
||||
@ -196,8 +194,8 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* See: https://github.com/webpack-contrib/file-loader#options
|
||||
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
|
||||
*
|
||||
* @type {Omit<typeof import('file-loader')['Options'], 'name'>}
|
||||
* @default
|
||||
* ```ts
|
||||
* { esModule: false, limit: 1000 }
|
||||
@ -207,12 +205,14 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* See: https://pugjs.org/api/reference.html#options
|
||||
*
|
||||
* @type {typeof import('pug')['Options']}
|
||||
*/
|
||||
pugPlain: {},
|
||||
|
||||
/**
|
||||
* See [vue-loader](https://github.com/vuejs/vue-loader) for available options.
|
||||
*
|
||||
* @type {Partial<typeof import('vue-loader')['VueLoaderOptions']>}
|
||||
*/
|
||||
vue: {
|
||||
@ -224,13 +224,13 @@ export default defineUntypedSchema({
|
||||
},
|
||||
compilerOptions: { $resolve: async (val, get) => val ?? (await get('vue.compilerOptions')) },
|
||||
propsDestructure: { $resolve: async (val, get) => val ?? Boolean(await get('vue.propsDestructure')) },
|
||||
defineModel: { $resolve: async (val, get) => val ?? Boolean(await get('vue.defineModel')) },
|
||||
defineModel: { $resolve: async (val, get) => val ?? Boolean(await get('vue.defineModel')) }
|
||||
},
|
||||
|
||||
css: {
|
||||
importLoaders: 0,
|
||||
url: {
|
||||
filter: (url: string, resourcePath: string) => !url.startsWith('/'),
|
||||
filter: (url: string, _resourcePath: string) => !url.startsWith('/')
|
||||
},
|
||||
esModule: false
|
||||
},
|
||||
@ -238,7 +238,7 @@ export default defineUntypedSchema({
|
||||
cssModules: {
|
||||
importLoaders: 0,
|
||||
url: {
|
||||
filter: (url: string, resourcePath: string) => !url.startsWith('/'),
|
||||
filter: (url: string, _resourcePath: string) => !url.startsWith('/')
|
||||
},
|
||||
esModule: false,
|
||||
modules: {
|
||||
@ -253,8 +253,8 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* See: https://github.com/webpack-contrib/sass-loader#options
|
||||
*
|
||||
* @type {typeof import('sass-loader')['Options']}
|
||||
*
|
||||
* @default
|
||||
* ```ts
|
||||
* {
|
||||
@ -272,6 +272,7 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* See: https://github.com/webpack-contrib/sass-loader#options
|
||||
*
|
||||
* @type {typeof import('sass-loader')['Options']}
|
||||
*/
|
||||
scss: {},
|
||||
@ -312,7 +313,6 @@ export default defineUntypedSchema({
|
||||
* Defaults to true when `extractCSS` is enabled.
|
||||
*
|
||||
* @see [css-minimizer-webpack-plugin documentation](https://github.com/webpack-contrib/css-minimizer-webpack-plugin).
|
||||
*
|
||||
* @type {false | typeof import('css-minimizer-webpack-plugin').BasePluginOptions & typeof import('css-minimizer-webpack-plugin').DefinedDefaultMinimizerAndOptions<any>}
|
||||
*/
|
||||
optimizeCSS: {
|
||||
@ -321,6 +321,7 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* Configure [webpack optimization](https://webpack.js.org/configuration/optimization/).
|
||||
*
|
||||
* @type {false | typeof import('webpack').Configuration['optimization']}
|
||||
*/
|
||||
optimization: {
|
||||
@ -350,11 +351,12 @@ export default defineUntypedSchema({
|
||||
plugins: {
|
||||
$resolve: async (val, get) => val ?? (await get('postcss.plugins'))
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* See [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) for available options.
|
||||
*
|
||||
* @type {typeof import('webpack-dev-middleware').Options<typeof import('http').IncomingMessage, typeof import('http').ServerResponse>}
|
||||
*/
|
||||
devMiddleware: {
|
||||
@ -363,6 +365,7 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* See [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) for available options.
|
||||
*
|
||||
* @type {typeof import('webpack-hot-middleware').MiddlewareOptions & { client?: typeof import('webpack-hot-middleware').ClientOptions }}
|
||||
*/
|
||||
hotMiddleware: {},
|
||||
@ -374,12 +377,14 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* Filters to hide build warnings.
|
||||
*
|
||||
* @type {Array<(warn: typeof import('webpack').WebpackError) => boolean>}
|
||||
*/
|
||||
warningIgnoreFilters: [],
|
||||
|
||||
/**
|
||||
* Configure [webpack experiments](https://webpack.js.org/configuration/experiments/)
|
||||
*
|
||||
* @type {false | typeof import('webpack').Configuration['experiments']}
|
||||
*/
|
||||
experiments: {}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
// Types
|
||||
export * from './types/compatibility'
|
||||
export * from './types/components'
|
||||
|
@ -3,7 +3,6 @@ export interface NuxtCompatibility {
|
||||
* Required nuxt version in semver format.
|
||||
*
|
||||
* @example `^2.14.0` or `>=3.0.0-27219851.6e49637`.
|
||||
*
|
||||
*/
|
||||
nuxt?: string
|
||||
|
||||
@ -12,7 +11,7 @@ export interface NuxtCompatibility {
|
||||
*
|
||||
* - `true`: When using Nuxt 2, using bridge module is required.
|
||||
* - `false`: When using Nuxt 2, using bridge module is not supported.
|
||||
*/
|
||||
*/
|
||||
bridge?: boolean
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import type { KeepAliveProps, TransitionProps } from 'vue'
|
||||
import type { ConfigSchema } from '../../schema/config'
|
||||
import type { ServerOptions as ViteServerOptions, UserConfig as ViteUserConfig } from 'vite'
|
||||
import type { Options as VuePluginOptions } from '@vitejs/plugin-vue'
|
||||
import type { Options as VueJsxPluginOptions } from '@vitejs/plugin-vue-jsx'
|
||||
import type { AppHeadMetaObject } from './head'
|
||||
import type { Nuxt } from './nuxt'
|
||||
import type { SchemaDefinition } from 'untyped'
|
||||
import type { NitroRuntimeConfig, NitroRuntimeConfigApp } from 'nitropack'
|
||||
import type { ConfigSchema } from '../../schema/config'
|
||||
import type { Nuxt } from './nuxt'
|
||||
import type { AppHeadMetaObject } from './head'
|
||||
export type { SchemaDefinition } from 'untyped'
|
||||
|
||||
type DeepPartial<T> = T extends Function ? T : T extends Record<string, any> ? { [P in keyof T]?: DeepPartial<T[P]> } : T
|
||||
@ -63,22 +63,35 @@ type Overrideable<T extends Record<string, any>, Path extends string = ''> = {
|
||||
: never
|
||||
}
|
||||
|
||||
/** User configuration in `nuxt.config` file */
|
||||
export interface NuxtConfig extends DeepPartial<Omit<ConfigSchema, 'vite' | 'runtimeConfig'>> {
|
||||
// Avoid DeepPartial for vite config interface (#4772)
|
||||
vite?: ConfigSchema['vite']
|
||||
runtimeConfig?: Overrideable<RuntimeConfig>
|
||||
webpack?: DeepPartial<ConfigSchema['webpack']> & {
|
||||
$client?: DeepPartial<ConfigSchema['webpack']>
|
||||
$server?: DeepPartial<ConfigSchema['webpack']>
|
||||
}
|
||||
// Runtime Config
|
||||
|
||||
/**
|
||||
* Experimental custom config schema
|
||||
*
|
||||
* @see https://github.com/nuxt/nuxt/issues/15592
|
||||
*/
|
||||
$schema?: SchemaDefinition
|
||||
type RuntimeConfigNamespace = Record<string, unknown>
|
||||
|
||||
export interface PublicRuntimeConfig extends RuntimeConfigNamespace { }
|
||||
|
||||
export interface RuntimeConfig extends RuntimeConfigNamespace {
|
||||
app: NitroRuntimeConfigApp
|
||||
/** Only available on the server. */
|
||||
nitro?: NitroRuntimeConfig['nitro']
|
||||
public: PublicRuntimeConfig
|
||||
}
|
||||
|
||||
// User configuration in `nuxt.config` file
|
||||
export interface NuxtConfig extends DeepPartial<Omit<ConfigSchema, 'vite' | 'runtimeConfig'>> {
|
||||
// Avoid DeepPartial for vite config interface (#4772)
|
||||
vite?: ConfigSchema['vite']
|
||||
runtimeConfig?: Overrideable<RuntimeConfig>
|
||||
webpack?: DeepPartial<ConfigSchema['webpack']> & {
|
||||
$client?: DeepPartial<ConfigSchema['webpack']>
|
||||
$server?: DeepPartial<ConfigSchema['webpack']>
|
||||
}
|
||||
|
||||
/**
|
||||
* Experimental custom config schema
|
||||
*
|
||||
* @see https://github.com/nuxt/nuxt/issues/15592
|
||||
*/
|
||||
$schema?: SchemaDefinition
|
||||
}
|
||||
|
||||
// TODO: Expose ConfigLayer<T> from c12
|
||||
@ -92,7 +105,11 @@ export type NuxtConfigLayer = ConfigLayer<NuxtConfig & {
|
||||
rootDir: ConfigSchema['rootDir']
|
||||
}>
|
||||
|
||||
/** Normalized Nuxt options available as `nuxt.options.*` */
|
||||
export interface NuxtBuilder {
|
||||
bundle: (nuxt: Nuxt) => Promise<void>
|
||||
}
|
||||
|
||||
// Normalized Nuxt options available as `nuxt.options.*`
|
||||
export interface NuxtOptions extends Omit<ConfigSchema, 'builder' | 'webpack'> {
|
||||
sourcemap: Required<Exclude<ConfigSchema['sourcemap'], boolean>>
|
||||
builder: '@nuxt/vite-builder' | '@nuxt/webpack-builder' | NuxtBuilder
|
||||
@ -104,27 +121,26 @@ export interface NuxtOptions extends Omit<ConfigSchema, 'builder' | 'webpack'> {
|
||||
$schema: SchemaDefinition
|
||||
}
|
||||
|
||||
export interface NuxtBuilder {
|
||||
bundle: (nuxt: Nuxt) => Promise<void>
|
||||
}
|
||||
|
||||
export interface ViteConfig extends Omit<ViteUserConfig, 'publicDir'> {
|
||||
/** The path to the entrypoint for the Vite build. */
|
||||
entry?: string
|
||||
/**
|
||||
* Options passed to @vitejs/plugin-vue.
|
||||
*
|
||||
* @see https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue
|
||||
*/
|
||||
vue?: VuePluginOptions
|
||||
|
||||
/**
|
||||
* Options passed to @vitejs/plugin-vue-jsx.
|
||||
*
|
||||
* @see https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx
|
||||
*/
|
||||
vueJsx?: VueJsxPluginOptions
|
||||
|
||||
/**
|
||||
* Bundler for dev time server-side rendering.
|
||||
*
|
||||
* @default 'vite-node'
|
||||
*/
|
||||
devBundler?: 'vite-node' | 'legacy'
|
||||
@ -148,22 +164,7 @@ export interface ViteConfig extends Omit<ViteUserConfig, 'publicDir'> {
|
||||
publicDir?: never
|
||||
}
|
||||
|
||||
|
||||
// -- Runtime Config --
|
||||
|
||||
type RuntimeConfigNamespace = Record<string, unknown>
|
||||
|
||||
export interface PublicRuntimeConfig extends RuntimeConfigNamespace { }
|
||||
|
||||
export interface RuntimeConfig extends RuntimeConfigNamespace {
|
||||
app: NitroRuntimeConfigApp
|
||||
/** Only available on the server. */
|
||||
nitro?: NitroRuntimeConfig['nitro']
|
||||
public: PublicRuntimeConfig
|
||||
}
|
||||
|
||||
// -- App Config --
|
||||
|
||||
// App Config
|
||||
export interface CustomAppConfig {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
import type { TSConfig } from 'pkg-types'
|
||||
import type { Server as HttpServer } from 'node:http'
|
||||
import type { Server as HttpsServer } from 'node:https'
|
||||
import type { TSConfig } from 'pkg-types'
|
||||
import type { ViteDevServer } from 'vite'
|
||||
import type { Manifest } from 'vue-bundle-renderer'
|
||||
import type { EventHandler } from 'h3'
|
||||
import type { Import, InlinePreset, Unimport } from 'unimport'
|
||||
import type { Compiler, Configuration, Stats } from 'webpack'
|
||||
import type { Nuxt, NuxtApp, ResolvedNuxtTemplate } from './nuxt'
|
||||
import type { Nitro, NitroConfig } from 'nitropack'
|
||||
import type { Component, ComponentsOptions } from './components'
|
||||
import type { NuxtCompatibility, NuxtCompatibilityIssues, ViteConfig } from '..'
|
||||
import type { Schema, SchemaDefinition } from 'untyped'
|
||||
import type { RouteLocationRaw } from 'vue-router'
|
||||
import type { NuxtCompatibility, NuxtCompatibilityIssues, ViteConfig } from '..'
|
||||
import type { Component, ComponentsOptions } from './components'
|
||||
import type { Nuxt, NuxtApp, ResolvedNuxtTemplate } from './nuxt'
|
||||
|
||||
export type HookResult = Promise<void> | void
|
||||
|
||||
@ -65,6 +65,7 @@ export interface NuxtHooks {
|
||||
// Kit
|
||||
/**
|
||||
* Allows extending compatibility checks.
|
||||
*
|
||||
* @param compatibility Compatibility object
|
||||
* @param issues Issues to be mapped
|
||||
* @returns Promise
|
||||
@ -74,18 +75,21 @@ export interface NuxtHooks {
|
||||
// Nuxt
|
||||
/**
|
||||
* Called after Nuxt initialization, when the Nuxt instance is ready to work.
|
||||
*
|
||||
* @param nuxt The configured Nuxt object
|
||||
* @returns Promise
|
||||
*/
|
||||
'ready': (nuxt: Nuxt) => HookResult
|
||||
/**
|
||||
* Called when Nuxt instance is gracefully closing.
|
||||
*
|
||||
* @param nuxt The configured Nuxt object
|
||||
* @returns Promise
|
||||
*/
|
||||
'close': (nuxt: Nuxt) => HookResult
|
||||
/**
|
||||
* Called to restart the current Nuxt instance.
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
'restart': (options?: {
|
||||
@ -97,29 +101,34 @@ export interface NuxtHooks {
|
||||
|
||||
/**
|
||||
* Called during Nuxt initialization, before installing user modules.
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
'modules:before': () => HookResult
|
||||
/**
|
||||
* Called during Nuxt initialization, after installing user modules.
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
'modules:done': () => HookResult
|
||||
|
||||
/**
|
||||
* Called after resolving the `app` instance.
|
||||
*
|
||||
* @param app The resolved `NuxtApp` object
|
||||
* @returns Promise
|
||||
*/
|
||||
'app:resolve': (app: NuxtApp) => HookResult
|
||||
/**
|
||||
* Called during `NuxtApp` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.nuxt`).
|
||||
*
|
||||
* @param app The configured `NuxtApp` object
|
||||
* @returns Promise
|
||||
*/
|
||||
'app:templates': (app: NuxtApp) => HookResult
|
||||
/**
|
||||
* Called after templates are compiled into the [virtual file system](https://nuxt.com/docs/guide/directory-structure/nuxt#virtual-file-system) (vfs).
|
||||
*
|
||||
* @param app The configured `NuxtApp` object
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -127,16 +136,19 @@ export interface NuxtHooks {
|
||||
|
||||
/**
|
||||
* Called before Nuxt bundle builder.
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
'build:before': () => HookResult
|
||||
/**
|
||||
* Called after Nuxt bundle builder is complete.
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
'build:done': () => HookResult
|
||||
/**
|
||||
* Called during the manifest build by Vite and Webpack. This allows customizing the manifest that Nitro will use to render `<script>` and `<link>` tags in the final HTML.
|
||||
*
|
||||
* @param manifest The manifest object to build
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -144,6 +156,7 @@ export interface NuxtHooks {
|
||||
|
||||
/**
|
||||
* Called when `nuxt analyze` is finished
|
||||
*
|
||||
* @param meta the analyze meta object, mutations will be saved to `meta.json`
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -151,12 +164,14 @@ export interface NuxtHooks {
|
||||
|
||||
/**
|
||||
* Called before generating the app.
|
||||
*
|
||||
* @param options GenerateAppOptions object
|
||||
* @returns Promise
|
||||
*/
|
||||
'builder:generateApp': (options?: GenerateAppOptions) => HookResult
|
||||
/**
|
||||
* Called at build time in development when the watcher spots a change to a file or directory in the project.
|
||||
*
|
||||
* @param event "add" | "addDir" | "change" | "unlink" | "unlinkDir"
|
||||
* @param path the path to the watched file
|
||||
* @returns Promise
|
||||
@ -165,6 +180,7 @@ export interface NuxtHooks {
|
||||
|
||||
/**
|
||||
* Called after pages routes are resolved.
|
||||
*
|
||||
* @param pages Array containing resolved pages
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -172,6 +188,7 @@ export interface NuxtHooks {
|
||||
|
||||
/**
|
||||
* Called when the dev middleware is being registered on the Nitro dev server.
|
||||
*
|
||||
* @param handler the Vite or Webpack event handler
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -179,24 +196,28 @@ export interface NuxtHooks {
|
||||
|
||||
/**
|
||||
* Called at setup allowing modules to extend sources.
|
||||
*
|
||||
* @param presets Array containing presets objects
|
||||
* @returns Promise
|
||||
*/
|
||||
'imports:sources': (presets: ImportPresetWithDeprecation[]) => HookResult
|
||||
/**
|
||||
* Called at setup allowing modules to extend imports.
|
||||
*
|
||||
* @param imports Array containing the imports to extend
|
||||
* @returns Promise
|
||||
*/
|
||||
'imports:extend': (imports: Import[]) => HookResult
|
||||
/**
|
||||
* Called when the [unimport](https://github.com/unjs/unimport) context is created.
|
||||
*
|
||||
* @param context The Unimport context
|
||||
* @returns Promise
|
||||
*/
|
||||
'imports:context': (context: Unimport) => HookResult
|
||||
/**
|
||||
* Allows extending import directories.
|
||||
*
|
||||
* @param dirs Array containing directories as string
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -205,12 +226,14 @@ export interface NuxtHooks {
|
||||
// Components
|
||||
/**
|
||||
* Called within `app:resolve` allowing to extend the directories that are scanned for auto-importable components.
|
||||
*
|
||||
* @param dirs The `dirs` option to push new items
|
||||
* @returns Promise
|
||||
*/
|
||||
'components:dirs': (dirs: ComponentsOptions['dirs']) => HookResult
|
||||
/**
|
||||
* Allows extending new components.
|
||||
*
|
||||
* @param components The `components` array to push new items
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -219,30 +242,35 @@ export interface NuxtHooks {
|
||||
// Nitropack
|
||||
/**
|
||||
* Called before initializing Nitro, allowing customization of Nitro's configuration.
|
||||
*
|
||||
* @param nitroConfig The nitro config to be extended
|
||||
* @returns Promise
|
||||
*/
|
||||
'nitro:config': (nitroConfig: NitroConfig) => HookResult
|
||||
/**
|
||||
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
|
||||
*
|
||||
* @param nitro The created nitro object
|
||||
* @returns Promise
|
||||
*/
|
||||
'nitro:init': (nitro: Nitro) => HookResult
|
||||
/**
|
||||
* Called before building the Nitro instance.
|
||||
*
|
||||
* @param nitro The created nitro object
|
||||
* @returns Promise
|
||||
*/
|
||||
'nitro:build:before': (nitro: Nitro) => HookResult
|
||||
/**
|
||||
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
|
||||
*
|
||||
* @param nitro The created nitro object
|
||||
* @returns Promise
|
||||
*/
|
||||
'nitro:build:public-assets': (nitro: Nitro) => HookResult
|
||||
/**
|
||||
* Allows extending the routes to be pre-rendered.
|
||||
*
|
||||
* @param ctx Nuxt context
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -251,18 +279,21 @@ export interface NuxtHooks {
|
||||
// Nuxi
|
||||
/**
|
||||
* Called when an error occurs at build time.
|
||||
*
|
||||
* @param error Error object
|
||||
* @returns Promise
|
||||
*/
|
||||
'build:error': (error: Error) => HookResult
|
||||
/**
|
||||
* Called before Nuxi writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`
|
||||
*
|
||||
* @param options Objects containing `references`, `declarations`, `tsConfig`
|
||||
* @returns Promise
|
||||
*/
|
||||
'prepare:types': (options: { references: TSReference[], declarations: string[], tsConfig: TSConfig }) => HookResult
|
||||
/**
|
||||
* Called when the dev server is loading.
|
||||
*
|
||||
* @param listenerServer The HTTP/HTTPS server object
|
||||
* @param listener The server's listener object
|
||||
* @returns Promise
|
||||
@ -272,24 +303,28 @@ export interface NuxtHooks {
|
||||
// Schema
|
||||
/**
|
||||
* Allows extending default schemas.
|
||||
*
|
||||
* @param schemas Schemas to be extend
|
||||
* @returns void
|
||||
*/
|
||||
'schema:extend': (schemas: SchemaDefinition[]) => void
|
||||
/**
|
||||
* Allows extending resolved schema.
|
||||
*
|
||||
* @param schema Schema object
|
||||
* @returns void
|
||||
*/
|
||||
'schema:resolved': (schema: Schema) => void
|
||||
/**
|
||||
* Called before writing the given schema.
|
||||
*
|
||||
* @param schema Schema object
|
||||
* @returns void
|
||||
*/
|
||||
'schema:beforeWrite': (schema: Schema) => void
|
||||
/**
|
||||
* Called after the schema is written.
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
'schema:written': () => void
|
||||
@ -297,12 +332,14 @@ export interface NuxtHooks {
|
||||
// Vite
|
||||
/**
|
||||
* Allows to extend Vite default context.
|
||||
*
|
||||
* @param viteBuildContext The vite build context object
|
||||
* @returns Promise
|
||||
*/
|
||||
'vite:extend': (viteBuildContext: { nuxt: Nuxt, config: ViteConfig }) => HookResult
|
||||
/**
|
||||
* Allows to extend Vite default config.
|
||||
*
|
||||
* @param viteInlineConfig The vite inline config object
|
||||
* @param env Server or client
|
||||
* @returns Promise
|
||||
@ -310,6 +347,7 @@ export interface NuxtHooks {
|
||||
'vite:extendConfig': (viteInlineConfig: ViteConfig, env: { isClient: boolean, isServer: boolean }) => HookResult
|
||||
/**
|
||||
* Allows to read the resolved Vite config.
|
||||
*
|
||||
* @param viteInlineConfig The vite inline config object
|
||||
* @param env Server or client
|
||||
* @returns Promise
|
||||
@ -317,6 +355,7 @@ export interface NuxtHooks {
|
||||
'vite:configResolved': (viteInlineConfig: Readonly<ViteConfig>, env: { isClient: boolean, isServer: boolean }) => HookResult
|
||||
/**
|
||||
* Called when the Vite server is created.
|
||||
*
|
||||
* @param viteServer Vite development server
|
||||
* @param env Server or client
|
||||
* @returns Promise
|
||||
@ -324,6 +363,7 @@ export interface NuxtHooks {
|
||||
'vite:serverCreated': (viteServer: ViteDevServer, env: { isClient: boolean, isServer: boolean }) => HookResult
|
||||
/**
|
||||
* Called after Vite server is compiled.
|
||||
*
|
||||
* @returns Promise
|
||||
*/
|
||||
'vite:compiled': () => HookResult
|
||||
@ -331,24 +371,28 @@ export interface NuxtHooks {
|
||||
// webpack
|
||||
/**
|
||||
* Called before configuring the webpack compiler.
|
||||
*
|
||||
* @param webpackConfigs Configs objects to be pushed to the compiler
|
||||
* @returns Promise
|
||||
*/
|
||||
'webpack:config': (webpackConfigs: Configuration[]) => HookResult
|
||||
/**
|
||||
* Allows to read the resolved webpack config
|
||||
* @param webpackConfigs Configs objects to be pushed to the compiler
|
||||
* @returns Promise
|
||||
*/
|
||||
* Allows to read the resolved webpack config
|
||||
*
|
||||
* @param webpackConfigs Configs objects to be pushed to the compiler
|
||||
* @returns Promise
|
||||
*/
|
||||
'webpack:configResolved': (webpackConfigs: Readonly<Configuration>[]) => HookResult
|
||||
/**
|
||||
* Called right before compilation.
|
||||
*
|
||||
* @param options The options to be added
|
||||
* @returns Promise
|
||||
*/
|
||||
'webpack:compile': (options: { name: string, compiler: Compiler }) => HookResult
|
||||
/**
|
||||
* Called after resources are loaded.
|
||||
*
|
||||
* @param options The compiler options
|
||||
* @returns Promise
|
||||
*/
|
||||
@ -356,22 +400,26 @@ export interface NuxtHooks {
|
||||
|
||||
/**
|
||||
* Called on `change` on WebpackBar.
|
||||
*
|
||||
* @param shortPath the short path
|
||||
* @returns void
|
||||
*/
|
||||
'webpack:change': (shortPath: string) => void
|
||||
/**
|
||||
* Called on `done` if has errors on WebpackBar.
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
'webpack:error': () => void
|
||||
/**
|
||||
* Called on `allDone` on WebpackBar.
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
'webpack:done': () => void
|
||||
/**
|
||||
* Called on `progress` on WebpackBar.
|
||||
*
|
||||
* @param statesArray The array containing the states on progress
|
||||
* @returns void
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { NuxtHooks } from './hooks'
|
||||
import type { Nuxt } from "./nuxt"
|
||||
import type { Nuxt } from './nuxt'
|
||||
import type { NuxtCompatibility } from './compatibility'
|
||||
|
||||
export interface ModuleMeta {
|
||||
|
@ -4,6 +4,57 @@ import type { NuxtHooks, NuxtLayout, NuxtMiddleware } from './hooks'
|
||||
import type { Component } from './components'
|
||||
import type { NuxtOptions } from './config'
|
||||
|
||||
export interface NuxtPlugin {
|
||||
/** @deprecated use mode */
|
||||
ssr?: boolean
|
||||
src: string
|
||||
mode?: 'all' | 'server' | 'client'
|
||||
/**
|
||||
* This allows more granular control over plugin order and should only be used by advanced users.
|
||||
* Lower numbers run first, and user plugins default to `0`.
|
||||
*
|
||||
* Default Nuxt priorities can be seen at [here](https://github.com/nuxt/nuxt/blob/9904849bc87c53dfbd3ea3528140a5684c63c8d8/packages/nuxt/src/core/plugins/plugin-metadata.ts#L15-L34).
|
||||
*/
|
||||
order?: number
|
||||
}
|
||||
|
||||
export interface NuxtTemplate<Options = Record<string, any>> {
|
||||
/** resolved output file path (generated) */
|
||||
dst?: string
|
||||
/** The target filename once the template is copied into the Nuxt buildDir */
|
||||
filename?: string
|
||||
/** An options object that will be accessible within the template via `<% options %>` */
|
||||
options?: Options
|
||||
/** The resolved path to the source file to be template */
|
||||
src?: string
|
||||
/** Provided compile option instead of src */
|
||||
getContents?: (data: Options) => string | Promise<string>
|
||||
/** Write to filesystem */
|
||||
write?: boolean
|
||||
}
|
||||
|
||||
export interface ResolvedNuxtTemplate<Options = Record<string, any>> extends NuxtTemplate<Options> {
|
||||
filename: string
|
||||
dst: string
|
||||
}
|
||||
|
||||
type _TemplatePlugin<Options> = Omit<NuxtPlugin, 'src'> & NuxtTemplate<Options>
|
||||
export interface NuxtPluginTemplate<Options = Record<string, any>> extends _TemplatePlugin<Options> { }
|
||||
|
||||
export interface NuxtApp {
|
||||
mainComponent?: string | null
|
||||
rootComponent?: string | null
|
||||
errorComponent?: string | null
|
||||
dir: string
|
||||
extensions: string[]
|
||||
plugins: NuxtPlugin[]
|
||||
components: Component[]
|
||||
layouts: Record<string, NuxtLayout>
|
||||
middleware: NuxtMiddleware[]
|
||||
templates: NuxtTemplate[]
|
||||
configs: string[]
|
||||
}
|
||||
|
||||
export interface Nuxt {
|
||||
// Private fields.
|
||||
_version: string
|
||||
@ -26,54 +77,3 @@ export interface Nuxt {
|
||||
|
||||
apps: Record<string, NuxtApp>
|
||||
}
|
||||
|
||||
export interface NuxtTemplate<Options = Record<string, any>> {
|
||||
/** resolved output file path (generated) */
|
||||
dst?: string
|
||||
/** The target filename once the template is copied into the Nuxt buildDir */
|
||||
filename?: string
|
||||
/** An options object that will be accessible within the template via `<% options %>` */
|
||||
options?: Options
|
||||
/** The resolved path to the source file to be template */
|
||||
src?: string
|
||||
/** Provided compile option instead of src */
|
||||
getContents?: (data: Options) => string | Promise<string>
|
||||
/** Write to filesystem */
|
||||
write?: boolean
|
||||
}
|
||||
|
||||
export interface ResolvedNuxtTemplate<Options = Record<string, any>> extends NuxtTemplate<Options> {
|
||||
filename: string
|
||||
dst: string
|
||||
}
|
||||
|
||||
export interface NuxtPlugin {
|
||||
/** @deprecated use mode */
|
||||
ssr?: boolean
|
||||
src: string
|
||||
mode?: 'all' | 'server' | 'client'
|
||||
/**
|
||||
* This allows more granular control over plugin order and should only be used by advanced users.
|
||||
* Lower numbers run first, and user plugins default to `0`.
|
||||
*
|
||||
* Default Nuxt priorities can be seen at [here](https://github.com/nuxt/nuxt/blob/9904849bc87c53dfbd3ea3528140a5684c63c8d8/packages/nuxt/src/core/plugins/plugin-metadata.ts#L15-L34).
|
||||
*/
|
||||
order?: number
|
||||
}
|
||||
|
||||
export interface NuxtApp {
|
||||
mainComponent?: string | null
|
||||
rootComponent?: string | null
|
||||
errorComponent?: string | null
|
||||
dir: string
|
||||
extensions: string[]
|
||||
plugins: NuxtPlugin[]
|
||||
components: Component[]
|
||||
layouts: Record<string, NuxtLayout>
|
||||
middleware: NuxtMiddleware[]
|
||||
templates: NuxtTemplate[]
|
||||
configs: string[]
|
||||
}
|
||||
|
||||
type _TemplatePlugin<Options> = Omit<NuxtPlugin, 'src'> & NuxtTemplate<Options>
|
||||
export interface NuxtPluginTemplate<Options = Record<string, any>> extends _TemplatePlugin<Options> { }
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { RouterOptions as _RouterOptions, RouterHistory } from 'vue-router'
|
||||
|
||||
import type { RouterHistory, RouterOptions as _RouterOptions } from 'vue-router'
|
||||
|
||||
export type RouterOptions = Partial<Omit<_RouterOptions, 'history' | 'routes'>> & {
|
||||
history?: (baseURL?: string) => RouterHistory
|
||||
|
Loading…
Reference in New Issue
Block a user