fix(schema): warn if user provides vite.publicDir (#21847)

This commit is contained in:
Nozomu Ikuta 2023-07-05 18:59:23 +09:00 committed by GitHub
parent 52a427d583
commit 381e0f8349
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -30,7 +30,12 @@ export default defineUntypedSchema({
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
}, },
publicDir: { publicDir: {
$resolve: async (val, get) => val ?? resolve((await get('srcDir')), (await get('dir')).public) $resolve: async (val, get) => {
if (val) {
console.warn('Directly configuring the `vite.publicDir` option is not supported. Instead, set `dir.public`. You can read more in `https://nuxt.com/docs/api/configuration/nuxt-config#public`.')
}
return val ?? resolve((await get('srcDir')), (await get('dir')).public)
}
}, },
vue: { vue: {
isProduction: { isProduction: {

View File

@ -96,7 +96,7 @@ export interface NuxtOptions extends Omit<ConfigSchema, 'builder'> {
$schema: SchemaDefinition $schema: SchemaDefinition
} }
export interface ViteConfig extends ViteUserConfig { export interface ViteConfig extends Omit<ViteUserConfig, 'publicDir'> {
/** The path to the entrypoint for the Vite build. */ /** The path to the entrypoint for the Vite build. */
entry?: string entry?: string
/** /**
@ -126,6 +126,14 @@ export interface ViteConfig extends ViteUserConfig {
* Use environment variables or top level `server` options to configure Nuxt server. * Use environment variables or top level `server` options to configure Nuxt server.
*/ */
server?: Omit<ViteServerOptions, 'port' | 'host'> server?: Omit<ViteServerOptions, 'port' | 'host'>
/**
* Directly configuring the `vite.publicDir` option is not supported. Instead, set `dir.public`.
*
* You can read more in <https://nuxt.com/docs/api/configuration/nuxt-config#public>.
*
* @deprecated
*/
publicDir?: never
} }