-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(schema): warn if user provides vite.publicDir
#21847
fix(schema): warn if user provides vite.publicDir
#21847
Conversation
packages/schema/src/config/vite.ts
Outdated
@@ -30,6 +30,7 @@ export default defineUntypedSchema({ | |||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] | |||
}, | |||
publicDir: { | |||
$schema: { deprecated: 'use `dir.public` option instead' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, is this used for documentation auto-generation and no influence on coding actual application code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, the message is quoted from dir.static
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I deprecate it at docs level, developers still can specify vite.publicDir
option in Nuxt config file, because Nuxt accepts ViteConfig
as vite
option that extends/inherits all the properties from Vite's UserConfig
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's tricky. Setting $schema
here won't have any effect, as you say, because it's being shadowed by ViteConfig
. So instead we can set the deprecation on ViteConfig
directly.
packages/vite/src/vite.ts
Outdated
nuxt.hook('vite:extendConfig', (config) => { | ||
if (config.publicDir) { | ||
consola.warn('Using `options.vite.publicDir` option is not supported together with Nuxt. Use `options.dir.public` instead. You can read more in `https://nuxt.com/docs/api/configuration/nuxt-config#public`.') | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (config.publicDir) {...}
checks that config.publicDir !== false && config.publicDir !== ''
, both of which prevent public assets from being copied.
This warning message is shown twice in Terminal, because it's run for client build and server build. Should I show it only in either of them by checking isClient
or isServer
props?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the warning to schema so it will only warn when user options are read in. what do you think?
Did this work previously? I would think it would always be set as Nuxt schema should always resolve the publicDir
?
vite.publicDir
optionvite.publicDir
Oh, sorry I couldn't reply to your comments. |
π Linked issue
Resolves #21831
β Type of change
π Description
This PR is based on #21831 (comment)
I hope I'm doing it in right way and as @danielroe intended. π
References:
π Checklist