File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ export interface ResolvedOptions extends Options {
64
64
root : string
65
65
sourceMap : boolean
66
66
devServer ?: ViteDevServer
67
+ devToolsEnabled ?: boolean
67
68
}
68
69
69
70
export default function vuePlugin ( rawOptions : Options = { } ) : Plugin {
@@ -97,7 +98,8 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
97
98
customElement,
98
99
reactivityTransform,
99
100
root : process . cwd ( ) ,
100
- sourceMap : true
101
+ sourceMap : true ,
102
+ devToolsEnabled : process . env . NODE_ENV !== 'production'
101
103
}
102
104
103
105
// Temporal handling for 2.7 breaking change
@@ -135,7 +137,9 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
135
137
...options ,
136
138
root : config . root ,
137
139
sourceMap : config . command === 'build' ? ! ! config . build . sourcemap : true ,
138
- isProduction : config . isProduction
140
+ isProduction : config . isProduction ,
141
+ devToolsEnabled :
142
+ ! ! config . define ! . __VUE_PROD_DEVTOOLS__ || ! config . isProduction
139
143
}
140
144
} ,
141
145
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export async function transformMain(
27
27
ssr : boolean ,
28
28
asCustomElement : boolean
29
29
) {
30
- const { devServer, isProduction } = options
30
+ const { devServer, isProduction, devToolsEnabled } = options
31
31
32
32
// prev descriptor is only set and used for hmr
33
33
const prevDescriptor = getPrevDescriptor ( filename )
@@ -102,9 +102,12 @@ export async function transformMain(
102
102
if ( hasScoped ) {
103
103
attachedProps . push ( [ `__scopeId` , JSON . stringify ( `data-v-${ descriptor . id } ` ) ] )
104
104
}
105
- if ( devServer && ! isProduction ) {
105
+ if ( devToolsEnabled || ( devServer && ! isProduction ) ) {
106
106
// expose filename during serve for devtools to pickup
107
- attachedProps . push ( [ `__file` , JSON . stringify ( filename ) ] )
107
+ attachedProps . push ( [
108
+ `__file` ,
109
+ JSON . stringify ( isProduction ? path . basename ( filename ) : filename )
110
+ ] )
108
111
}
109
112
110
113
// HMR
You can’t perform that action at this time.
0 commit comments