File tree 3 files changed +15
-6
lines changed
3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,15 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
67
67
68
68
handleHotUpdate,
69
69
70
+ config ( config ) {
71
+ // provide default values for vue runtime esm defines
72
+ config . define = {
73
+ __VUE_OPTIONS_API__ : true ,
74
+ __VUE_PROD_DEVTOOLS__ : false ,
75
+ ...config . define
76
+ }
77
+ } ,
78
+
70
79
configResolved ( config ) {
71
80
options = {
72
81
...options ,
Original file line number Diff line number Diff line change @@ -90,15 +90,15 @@ export async function transformMain(
90
90
output . push ( 'export default _sfc_main' )
91
91
92
92
// HMR
93
- if ( devServer ) {
94
- // check if the template is the only thing that changed
95
- if ( prevDescriptor && isOnlyTemplateChanged ( prevDescriptor , descriptor ) ) {
96
- output . push ( `export const _rerender_only = true` )
97
- }
93
+ if ( devServer && ! isProduction ) {
98
94
output . push ( `_sfc_main.__hmrId = ${ JSON . stringify ( descriptor . id ) } ` )
99
95
output . push (
100
96
`__VUE_HMR_RUNTIME__.createRecord(_sfc_main.__hmrId, _sfc_main)`
101
97
)
98
+ // check if the template is the only thing that changed
99
+ if ( prevDescriptor && isOnlyTemplateChanged ( prevDescriptor , descriptor ) ) {
100
+ output . push ( `export const _rerender_only = true` )
101
+ }
102
102
output . push (
103
103
`import.meta.hot.accept(({ default: updated, _rerender_only }) => {` ,
104
104
` if (_rerender_only) {` ,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export function transformTemplateAsModule(
19
19
const result = compile ( code , descriptor , options , pluginContext )
20
20
21
21
let returnCode = result . code
22
- if ( options . devServer ) {
22
+ if ( options . devServer && ! options . isProduction ) {
23
23
returnCode += `\nimport.meta.hot.accept(({ render }) => {
24
24
__VUE_HMR_RUNTIME__.rerender(${ JSON . stringify ( descriptor . id ) } , render)
25
25
})`
You can’t perform that action at this time.
0 commit comments