2022-10-27 10:36:37 +00:00
import { defineUntypedSchema } from 'untyped'
2023-01-30 12:09:48 +00:00
import { defu } from 'defu'
2023-06-20 18:55:20 +00:00
import { resolve } from 'pathe'
2023-03-10 08:01:21 +00:00
import type { AppHeadMetaObject } from '../types/head'
2022-10-27 10:36:37 +00:00
export default defineUntypedSchema ( {
/ * *
* Vue . js config
* /
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 }
* /
2023-04-06 11:51:32 +00:00
compilerOptions : { } ,
2023-05-01 16:39:07 +00:00
/ * *
* Include Vue compiler in runtime bundle .
* /
runtimeCompiler : {
2023-08-08 20:55:29 +00:00
$resolve : async ( val , get ) = > val ? ? await get ( 'experimental.runtimeVueCompiler' ) ? ? false
2023-05-01 16:39:07 +00:00
} ,
2023-06-04 23:06:01 +00:00
/ * *
* Vue Experimental : Enable reactive destructure for ` defineProps `
* @see [ Vue RFC # 502 ] ( https : //github.com/vuejs/rfcs/discussions/502)
* @type { boolean }
* /
propsDestructure : false ,
2022-10-27 10:36:37 +00:00
} ,
/ * *
* Nuxt App configuration .
* /
app : {
/ * *
* 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 : {
2023-08-08 20:55:29 +00:00
$resolve : val = > val || process . env . NUXT_APP_BASE_URL || '/'
2022-10-27 10:36:37 +00:00
} ,
/** 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 : {
2023-08-08 20:55:29 +00:00
$resolve : val = > val || process . env . NUXT_APP_BUILD_ASSETS_DIR || '/_nuxt/'
2022-10-27 10:36:37 +00:00
} ,
/ * *
* 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
* ` ` `
* /
cdnURL : {
$resolve : async ( val , get ) = > ( await get ( 'dev' ) ) ? '' : ( process . env . NUXT_APP_CDN_URL ? ? val ) || ''
} ,
/ * *
* Set default configuration for ` <head> ` on every page .
* @example
* ` ` ` js
* app : {
* head : {
* meta : [
* // <meta name="viewport" content="width=device-width, initial-scale=1">
* { name : 'viewport' , content : 'width=device-width, initial-scale=1' }
* ] ,
* script : [
* // <script src="https://myawesome-lib.js"></script>
* { src : 'https://awesome-lib.js' }
* ] ,
* link : [
* // <link rel="stylesheet" href="https://myawesome-lib.css">
* { rel : 'stylesheet' , href : 'https://awesome-lib.css' }
* ] ,
* // please note that this is an area that is likely to change
* style : [
* // <style type="text/css">:root { color: red }</style>
* { children : ':root { color: red }' , type : 'text/css' }
* ] ,
* noscript : [
2023-01-13 15:00:57 +00:00
* // <noscript>JavaScript is required</noscript>
* { children : 'JavaScript is required' }
2022-10-27 10:36:37 +00:00
* ]
* }
* }
* ` ` `
* @type { typeof import ( '../src/types/config' ) . NuxtAppConfig [ 'head' ] }
* /
head : {
$resolve : async ( val , get ) = > {
const resolved : Required < AppHeadMetaObject > = defu ( val , await get ( 'meta' ) , {
meta : [ ] ,
link : [ ] ,
style : [ ] ,
script : [ ] ,
noscript : [ ]
} )
// provides default charset and viewport if not set
if ( ! resolved . meta . find ( m = > m . charset ) ? . charset ) {
resolved . meta . unshift ( { charset : resolved.charset || 'utf-8' } )
}
if ( ! resolved . meta . find ( m = > m . name === 'viewport' ) ? . content ) {
resolved . meta . unshift ( { name : 'viewport' , content : resolved.viewport || 'width=device-width, initial-scale=1' } )
}
resolved . meta = resolved . meta . filter ( Boolean )
resolved . link = resolved . link . filter ( Boolean )
resolved . style = resolved . style . filter ( Boolean )
resolved . script = resolved . script . filter ( Boolean )
resolved . noscript = resolved . noscript . filter ( Boolean )
return resolved
}
} ,
/ * *
* Default values for layout transitions .
*
* This can be overridden with ` definePageMeta ` on an individual page .
* Only JSON - serializable values are allowed .
* @see https : //vuejs.org/api/built-in-components.html#transition
* @type { typeof import ( '../src/types/config' ) . NuxtAppConfig [ 'layoutTransition' ] }
* /
layoutTransition : false ,
/ * *
* Default values for page transitions .
*
* This can be overridden with ` definePageMeta ` on an individual page .
* Only JSON - serializable values are allowed .
* @see https : //vuejs.org/api/built-in-components.html#transition
* @type { typeof import ( '../src/types/config' ) . NuxtAppConfig [ 'pageTransition' ] }
* /
pageTransition : false ,
2024-01-29 12:23:51 +00:00
/ * *
* Default values for view transitions .
*
* This only has an effect when * * experimental * * support for View Transitions is
* [ enabled in your nuxt . config file ] ( / d o c s / g e t t i n g - s t a r t e d / t r a n s i t i o n s # v i e w - t r a n s i t i o n s - a p i - e x p e r i m e n t a l ) .
*
* This can be overridden with ` definePageMeta ` on an individual page .
* @see https : //nuxt.com/docs/getting-started/transitions#view-transitions-api-experimental
* @type { typeof import ( '../src/types/config' ) . NuxtAppConfig [ 'viewTransition' ] }
* /
viewTransition : {
$resolve : async ( val , get ) = > val ? ? await get ( 'experimental.viewTransition' ) ? ? false
} ,
2022-10-27 10:36:37 +00:00
/ * *
* Default values for KeepAlive configuration between pages .
*
* This can be overridden with ` definePageMeta ` on an individual page .
* Only JSON - serializable values are allowed .
* @see https : //vuejs.org/api/built-in-components.html#keepalive
* @type { typeof import ( '../src/types/config' ) . NuxtAppConfig [ 'keepalive' ] }
* /
keepalive : false ,
2022-11-10 11:41:02 +00:00
/ * *
* Customize Nuxt root element id .
2023-08-12 07:19:36 +00:00
* @type { string | false }
2022-11-10 11:41:02 +00:00
* /
2023-08-09 07:29:08 +00:00
rootId : {
2023-08-12 07:19:36 +00:00
$resolve : val = > val === false ? false : val || '__nuxt'
2023-08-09 07:29:08 +00:00
} ,
2022-11-10 11:41:02 +00:00
/ * *
* Customize Nuxt root element tag .
* /
2023-08-09 07:29:08 +00:00
rootTag : {
$resolve : val = > val || 'div'
}
2022-10-27 10:36:37 +00:00
} ,
2023-08-08 20:55:29 +00:00
/ * *
2023-09-11 11:02:28 +00:00
* Boolean or a path to an HTML file with the contents of which will be inserted into any HTML page
2023-06-20 18:55:20 +00:00
* rendered with ` ssr: false ` .
2023-12-13 11:54:56 +00:00
* - If it is unset , it will use ` ~/app/spa-loading-template.html ` file in one of your layers , if it exists .
2023-09-11 11:02:28 +00:00
* - If it is false , no SPA loading indicator will be loaded .
2023-12-13 11:54:56 +00:00
* - If true , Nuxt will look for ` ~/app/spa-loading-template.html ` file in one of your layers , or a
* default Nuxt image will be used .
2023-06-20 18:55:20 +00:00
*
* Some good sources for spinners are [ SpinKit ] ( https : //github.com/tobiasahlin/SpinKit) or [SVG Spinners](https://icones.js.org/collection/svg-spinners).
* @example ~ / a p p / s p a - l o a d i n g - t e m p l a t e . h t m l
* ` ` ` html
* <!-- https : //github.com/barelyhuman/snips/blob/dev/pages/css-loader.md -->
* < div class = "loader" > < / div >
* < style >
* . loader {
* display : block ;
* position : fixed ;
* z - index : 1031 ;
* top : 50 % ;
* left : 50 % ;
* transform : translate ( - 50 % , - 50 % ) ;
* width : 18px ;
* height : 18px ;
* box - sizing : border - box ;
* border : solid 2 px transparent ;
* border - top - color : # 000 ;
* border - left - color : # 000 ;
* border - bottom - color : # efefef ;
* border - right - color : # efefef ;
* border - radius : 50 % ;
* - webkit - animation : loader 400 ms linear infinite ;
* animation : loader 400 ms linear infinite ;
* }
*
* \ @ - webkit - keyframes loader {
* 0 % {
2023-06-26 19:11:11 +00:00
* - webkit - transform : translate ( - 50 % , - 50 % ) rotate ( 0 deg ) ;
2023-06-20 18:55:20 +00:00
* }
* 100 % {
2023-06-26 19:11:11 +00:00
* - webkit - transform : translate ( - 50 % , - 50 % ) rotate ( 360 deg ) ;
2023-06-20 18:55:20 +00:00
* }
* }
* \ @keyframes loader {
* 0 % {
2023-06-26 19:11:11 +00:00
* transform : translate ( - 50 % , - 50 % ) rotate ( 0 deg ) ;
2023-06-20 18:55:20 +00:00
* }
* 100 % {
2023-06-26 19:11:11 +00:00
* transform : translate ( - 50 % , - 50 % ) rotate ( 360 deg ) ;
2023-06-20 18:55:20 +00:00
* }
* }
* < / style >
* ` ` `
2023-08-25 12:26:23 +00:00
* @type { string | boolean }
2023-06-20 18:55:20 +00:00
* /
spaLoadingTemplate : {
2023-09-11 12:07:28 +00:00
$resolve : async ( val , get ) = > typeof val === 'string' ? resolve ( await get ( 'srcDir' ) , val ) : val ? ? null
2023-06-20 18:55:20 +00:00
} ,
2022-10-27 10:36:37 +00:00
/ * *
* An array of nuxt app plugins .
*
* Each plugin can be a string ( which can be an absolute or relative path to a file ) .
* If it ends with ` .client ` or ` .server ` then it will be automatically loaded only
* in the appropriate context .
*
* It can also be an object with ` src ` and ` mode ` keys .
2023-01-02 18:18:50 +00:00
* @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
2022-10-27 10:36:37 +00:00
* @example
* ` ` ` js
* plugins : [
* '~/plugins/foo.client.js' , // only in client side
* '~/plugins/bar.server.js' , // only in server side
* '~/plugins/baz.js' , // both client & server
* { src : '~/plugins/both-sides.js' } ,
* { src : '~/plugins/client-only.js' , mode : 'client' } , // only on client side
* { src : '~/plugins/server-only.js' , mode : 'server' } // only on server side
* ]
* ` ` `
* @type { ( typeof import ( '../src/types/nuxt' ) . NuxtPlugin | string ) [ ] }
* /
plugins : [ ] ,
/ * *
* You can define the CSS files / module s / l i b r a r i e s y o u w a n t t o s e t g l o b a l l y
* ( included in every page ) .
*
* Nuxt will automatically guess the file type by its extension and use the
* appropriate pre - processor . You will still need to install the required
* loader if you need to use them .
* @example
* ` ` ` js
* css : [
* // Load a Node.js module directly (here it's a Sass file).
* 'bulma' ,
* // CSS file in the project
2023-12-05 12:40:04 +00:00
* '~/assets/css/main.css' ,
2022-10-27 10:36:37 +00:00
* // SCSS file in the project
2023-12-05 12:40:04 +00:00
* '~/assets/css/main.scss'
2022-10-27 10:36:37 +00:00
* ]
* ` ` `
* @type { string [ ] }
* /
css : {
$resolve : val = > ( val ? ? [ ] ) . map ( ( c : any ) = > c . src || c )
}
} )