4
4
parseVuePartRequest ,
5
5
resolveVuePart ,
6
6
isVuePartRequest ,
7
- transformRequireToImport ,
7
+ transformRequireToImport
8
8
} from './utils'
9
9
import {
10
10
createDefaultCompiler ,
@@ -13,15 +13,15 @@ import {
13
13
StyleOptions ,
14
14
TemplateOptions ,
15
15
StyleCompileResult ,
16
- DescriptorCompileResult ,
16
+ DescriptorCompileResult
17
17
} from '@vue/component-compiler'
18
18
import { Plugin , RawSourceMap } from 'rollup'
19
19
import * as path from 'path'
20
20
import { parse , SFCDescriptor , SFCBlock } from '@vue/component-compiler-utils'
21
21
import debug from 'debug'
22
22
import {
23
23
VueTemplateCompiler ,
24
- VueTemplateCompilerParseOptions ,
24
+ VueTemplateCompilerParseOptions
25
25
} from '@vue/component-compiler-utils/dist/types'
26
26
27
27
const templateCompiler = require ( 'vue-template-compiler' )
@@ -118,8 +118,11 @@ export interface VuePluginOptions {
118
118
*/
119
119
export default function vue ( opts : VuePluginOptions = { } ) : Plugin {
120
120
const isVue = createVueFilter ( opts . include , opts . exclude )
121
- const isProduction = ( opts . template && opts . template . isProduction ) ||
122
- process . env . NODE_ENV === 'production' || process . env . BUILD === 'production'
121
+ const isProduction =
122
+ opts . template && typeof opts . template . isProduction === 'boolean'
123
+ ? opts . template . isProduction
124
+ : process . env . NODE_ENV === 'production' ||
125
+ process . env . BUILD === 'production'
123
126
124
127
d ( 'Version ' + version )
125
128
d ( `Build environment: ${ isProduction ? 'production' : 'development' } ` )
@@ -128,13 +131,15 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
128
131
if ( ! opts . normalizer )
129
132
opts . normalizer = '~' + 'vue-runtime-helpers/dist/normalize-component.js'
130
133
if ( ! opts . styleInjector )
131
- opts . styleInjector = '~' + 'vue-runtime-helpers/dist/inject-style/browser.js'
134
+ opts . styleInjector =
135
+ '~' + 'vue-runtime-helpers/dist/inject-style/browser.js'
132
136
if ( ! opts . styleInjectorSSR )
133
- opts . styleInjectorSSR = '~' + 'vue-runtime-helpers/dist/inject-style/server.js'
137
+ opts . styleInjectorSSR =
138
+ '~' + 'vue-runtime-helpers/dist/inject-style/server.js'
134
139
135
140
createVuePartRequest . defaultLang = {
136
141
...createVuePartRequest . defaultLang ,
137
- ...opts . defaultLang ,
142
+ ...opts . defaultLang
138
143
}
139
144
140
145
const shouldExtractCss = opts . css === false
@@ -162,9 +167,9 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
162
167
video : [ 'src' , 'poster' ] ,
163
168
source : 'src' ,
164
169
img : 'src' ,
165
- image : 'xlink:href' ,
170
+ image : 'xlink:href'
166
171
} ,
167
- ...opts . template ,
172
+ ...opts . template
168
173
} as any
169
174
if ( opts . template && typeof opts . template . isProduction === 'undefined' ) {
170
175
opts . template . isProduction = isProduction
@@ -194,7 +199,9 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
194
199
if ( src . startsWith ( '.' ) ) {
195
200
return path . resolve ( path . dirname ( ref . filename ) , src as string )
196
201
} else {
197
- return require . resolve ( src , { paths : [ path . dirname ( ref . filename ) ] } )
202
+ return require . resolve ( src , {
203
+ paths : [ path . dirname ( ref . filename ) ]
204
+ } )
198
205
}
199
206
}
200
207
@@ -230,7 +237,7 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
230
237
compiler : opts . compiler || templateCompiler ,
231
238
compilerParseOptions : opts . compilerParseOptions ,
232
239
sourceRoot : opts . sourceRoot ,
233
- needMap : true ,
240
+ needMap : true
234
241
} )
235
242
)
236
243
)
@@ -257,7 +264,7 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
257
264
const input : any = {
258
265
scopeId,
259
266
styles,
260
- customBlocks : [ ] ,
267
+ customBlocks : [ ]
261
268
}
262
269
263
270
if ( descriptor . template ) {
@@ -297,7 +304,7 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
297
304
? JSON . stringify ( path . basename ( filename ) )
298
305
: JSON . stringify ( filename )
299
306
}
300
- ` ,
307
+ `
301
308
}
302
309
: { code : '' }
303
310
@@ -352,6 +359,6 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
352
359
353
360
return result
354
361
}
355
- } ,
362
+ }
356
363
}
357
364
}
0 commit comments