2022-02-25 19:11:01 +00:00
|
|
|
import { resolve } from 'pathe'
|
2022-07-21 10:44:33 +00:00
|
|
|
import { withoutLeadingSlash } from 'ufo'
|
2022-08-26 15:47:29 +00:00
|
|
|
import { defineUntypedSchema } from 'untyped'
|
2022-02-25 19:11:01 +00:00
|
|
|
|
2022-08-26 15:47:29 +00:00
|
|
|
export default defineUntypedSchema({
|
2022-02-25 19:11:01 +00:00
|
|
|
/**
|
|
|
|
* Configuration that will be passed directly to Vite.
|
|
|
|
*
|
|
|
|
* See https://vitejs.dev/config for more information.
|
|
|
|
* Please note that not all vite options are supported in Nuxt.
|
|
|
|
*
|
2022-07-29 10:57:45 +00:00
|
|
|
* @type {typeof import('../src/types/config').ViteConfig}
|
2022-02-25 19:11:01 +00:00
|
|
|
* @version 3
|
|
|
|
*/
|
|
|
|
vite: {
|
|
|
|
root: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => val ?? (await get('srcDir'))
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
|
|
|
mode: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => val ?? (await get('dev') ? 'development' : 'production')
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
|
|
|
logLevel: 'warn',
|
|
|
|
define: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => ({
|
|
|
|
'process.dev': await get('dev'),
|
2022-02-25 19:11:01 +00:00
|
|
|
...val || {}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
resolve: {
|
2022-08-11 21:25:35 +00:00
|
|
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
|
|
|
publicDir: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => val ?? resolve((await get('srcDir')), (await get('dir')).public)
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
|
|
|
vue: {
|
|
|
|
isProduction: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => val ?? !(await get('dev'))
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
2022-08-11 21:25:35 +00:00
|
|
|
template: {
|
|
|
|
compilerOptions: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => val ?? (await get('vue')).compilerOptions
|
2022-08-11 21:25:35 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
|
|
|
optimizeDeps: {
|
|
|
|
exclude: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => [
|
2022-02-25 19:11:01 +00:00
|
|
|
...val || [],
|
2022-09-12 18:22:41 +00:00
|
|
|
...(await get('build.transpile')).filter((i: string) => typeof i === 'string'),
|
2022-08-11 21:25:35 +00:00
|
|
|
'vue-demi'
|
|
|
|
]
|
|
|
|
}
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
|
|
|
esbuild: {
|
|
|
|
jsxFactory: 'h',
|
|
|
|
jsxFragment: 'Fragment',
|
|
|
|
tsconfigRaw: '{}'
|
|
|
|
},
|
|
|
|
clearScreen: false,
|
|
|
|
build: {
|
|
|
|
assetsDir: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => val ?? withoutLeadingSlash((await get('app')).buildAssetsDir)
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
2022-08-11 21:25:35 +00:00
|
|
|
emptyOutDir: false
|
2022-02-25 19:11:01 +00:00
|
|
|
},
|
|
|
|
server: {
|
|
|
|
fs: {
|
|
|
|
strict: false,
|
|
|
|
allow: {
|
2022-09-12 18:22:41 +00:00
|
|
|
$resolve: async (val, get) => [
|
|
|
|
await get('buildDir'),
|
|
|
|
await get('srcDir'),
|
|
|
|
await get('rootDir'),
|
|
|
|
...(await get('modulesDir')),
|
2022-02-25 19:11:01 +00:00
|
|
|
...val ?? []
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-26 15:47:29 +00:00
|
|
|
})
|