44 parseVuePartRequest ,
55 resolveVuePart ,
66 isVuePartRequest ,
7- transformRequireToImport ,
7+ transformRequireToImport
88} from './utils'
99import {
1010 createDefaultCompiler ,
@@ -13,15 +13,15 @@ import {
1313 StyleOptions ,
1414 TemplateOptions ,
1515 StyleCompileResult ,
16- DescriptorCompileResult ,
16+ DescriptorCompileResult
1717} from '@vue/component-compiler'
1818import { Plugin , RawSourceMap } from 'rollup'
1919import * as path from 'path'
2020import { parse , SFCDescriptor , SFCBlock } from '@vue/component-compiler-utils'
2121import debug from 'debug'
2222import {
2323 VueTemplateCompiler ,
24- VueTemplateCompilerParseOptions ,
24+ VueTemplateCompilerParseOptions
2525} from '@vue/component-compiler-utils/dist/types'
2626
2727const templateCompiler = require ( 'vue-template-compiler' )
@@ -118,8 +118,11 @@ export interface VuePluginOptions {
118118 */
119119export default function vue ( opts : VuePluginOptions = { } ) : Plugin {
120120 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'
123126
124127 d ( 'Version ' + version )
125128 d ( `Build environment: ${ isProduction ? 'production' : 'development' } ` )
@@ -128,13 +131,15 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
128131 if ( ! opts . normalizer )
129132 opts . normalizer = '~' + 'vue-runtime-helpers/dist/normalize-component.js'
130133 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'
132136 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'
134139
135140 createVuePartRequest . defaultLang = {
136141 ...createVuePartRequest . defaultLang ,
137- ...opts . defaultLang ,
142+ ...opts . defaultLang
138143 }
139144
140145 const shouldExtractCss = opts . css === false
@@ -162,9 +167,9 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
162167 video : [ 'src' , 'poster' ] ,
163168 source : 'src' ,
164169 img : 'src' ,
165- image : 'xlink:href' ,
170+ image : 'xlink:href'
166171 } ,
167- ...opts . template ,
172+ ...opts . template
168173 } as any
169174 if ( opts . template && typeof opts . template . isProduction === 'undefined' ) {
170175 opts . template . isProduction = isProduction
@@ -194,7 +199,9 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
194199 if ( src . startsWith ( '.' ) ) {
195200 return path . resolve ( path . dirname ( ref . filename ) , src as string )
196201 } else {
197- return require . resolve ( src , { paths : [ path . dirname ( ref . filename ) ] } )
202+ return require . resolve ( src , {
203+ paths : [ path . dirname ( ref . filename ) ]
204+ } )
198205 }
199206 }
200207
@@ -230,7 +237,7 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
230237 compiler : opts . compiler || templateCompiler ,
231238 compilerParseOptions : opts . compilerParseOptions ,
232239 sourceRoot : opts . sourceRoot ,
233- needMap : true ,
240+ needMap : true
234241 } )
235242 )
236243 )
@@ -257,7 +264,7 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
257264 const input : any = {
258265 scopeId,
259266 styles,
260- customBlocks : [ ] ,
267+ customBlocks : [ ]
261268 }
262269
263270 if ( descriptor . template ) {
@@ -297,7 +304,7 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
297304 ? JSON . stringify ( path . basename ( filename ) )
298305 : JSON . stringify ( filename )
299306 }
300- ` ,
307+ `
301308 }
302309 : { code : '' }
303310
@@ -352,6 +359,6 @@ export default function vue(opts: VuePluginOptions = {}): Plugin {
352359
353360 return result
354361 }
355- } ,
362+ }
356363 }
357364}
0 commit comments