@@ -33,6 +33,9 @@ export interface Options {
3333 include ?: string | RegExp | ( string | RegExp ) [ ]
3434 exclude ?: string | RegExp | ( string | RegExp ) [ ]
3535
36+ /**
37+ * In Vite, this option follows Vite's config.
38+ */
3639 isProduction ?: boolean
3740
3841 // options to pass on to vue/compiler-sfc
@@ -47,6 +50,7 @@ export interface Options {
4750 | 'genDefaultAs'
4851 | 'customElement'
4952 | 'defineModel'
53+ | 'propsDestructure'
5054 >
5155 > & {
5256 /**
@@ -88,19 +92,37 @@ export interface Options {
8892 | 'preprocessOptions'
8993 >
9094 >
95+
9196 /**
92- * Transform Vue SFCs into custom elements.
93- * - `true`: all `*.vue` imports are converted into custom elements
94- * - `string | RegExp`: matched files are converted into custom elements
95- *
96- * @default /\.ce\.vue$/
97+ * @deprecated moved to `features.customElement`.
9798 */
9899 customElement ?: boolean | string | RegExp | ( string | RegExp ) [ ]
99100
100101 /**
101102 * Use custom compiler-sfc instance. Can be used to force a specific version.
102103 */
103104 compiler ?: typeof _compiler
105+
106+ features ?: {
107+ optionsAPI ?: boolean
108+ prodDevtools ?: boolean
109+ prodHydrationMismatchDetails ?: boolean
110+ /**
111+ * Enable reactive destructure for `defineProps`.
112+ * - Available in Vue 3.4 and later.
113+ * - Defaults to true in Vue 3.5+
114+ * - Defaults to false in Vue 3.4 (**experimental**)
115+ */
116+ propsDestructure ?: boolean
117+ /**
118+ * Transform Vue SFCs into custom elements.
119+ * - `true`: all `*.vue` imports are converted into custom elements
120+ * - `string | RegExp`: matched files are converted into custom elements
121+ *
122+ * @default /\.ce\.vue$/
123+ */
124+ customElement ?: boolean | string | RegExp | ( string | RegExp ) [ ]
125+ }
104126}
105127
106128export interface ResolvedOptions extends Options {
@@ -128,17 +150,18 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
128150 root : process . cwd ( ) ,
129151 sourceMap : true ,
130152 cssDevSourcemap : false ,
131- devToolsEnabled : process . env . NODE_ENV !== 'production' ,
132153 } )
133154
134155 const filter = computed ( ( ) =>
135156 createFilter ( options . value . include , options . value . exclude ) ,
136157 )
137- const customElementFilter = computed ( ( ) =>
138- typeof options . value . customElement === 'boolean'
139- ? ( ) => options . value . customElement as boolean
140- : createFilter ( options . value . customElement ) ,
141- )
158+ const customElementFilter = computed ( ( ) => {
159+ const customElement =
160+ options . value . features ?. customElement || options . value . customElement
161+ return typeof customElement === 'boolean'
162+ ? ( ) => customElement
163+ : createFilter ( customElement )
164+ } )
142165
143166 return {
144167 name : 'vite:vue' ,
@@ -175,10 +198,18 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
175198 dedupe : config . build ?. ssr ? [ ] : [ 'vue' ] ,
176199 } ,
177200 define : {
178- __VUE_OPTIONS_API__ : config . define ?. __VUE_OPTIONS_API__ ?? true ,
179- __VUE_PROD_DEVTOOLS__ : config . define ?. __VUE_PROD_DEVTOOLS__ ?? false ,
201+ __VUE_OPTIONS_API__ :
202+ ( options . value . features ?. optionsAPI ||
203+ config . define ?. __VUE_OPTIONS_API__ ) ??
204+ true ,
205+ __VUE_PROD_DEVTOOLS__ :
206+ ( options . value . features ?. prodDevtools ||
207+ config . define ?. __VUE_PROD_DEVTOOLS__ ) ??
208+ false ,
180209 __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ :
181- config . define ?. __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ ?? false ,
210+ ( options . value . features ?. prodHydrationMismatchDetails ||
211+ config . define ?. __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ ) ??
212+ false ,
182213 } ,
183214 ssr : {
184215 // @ts -ignore -- config.legacy.buildSsrCjsExternalHeuristics will be removed in Vite 5
@@ -196,8 +227,11 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
196227 sourceMap : config . command === 'build' ? ! ! config . build . sourcemap : true ,
197228 cssDevSourcemap : config . css ?. devSourcemap ?? false ,
198229 isProduction : config . isProduction ,
199- devToolsEnabled :
200- ! ! config . define ! . __VUE_PROD_DEVTOOLS__ || ! config . isProduction ,
230+ devToolsEnabled : ! ! (
231+ options . value . features ?. prodDevtools ||
232+ config . define ! . __VUE_PROD_DEVTOOLS__ ||
233+ ! config . isProduction
234+ ) ,
201235 }
202236 } ,
203237
0 commit comments