File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 1
1
export const MODULE_NAME = 'vite-plugin-components'
2
2
export const RESOLVER_EXT = '.vite-plugin-components'
3
+ export const DISABLE_COMMENT = '/* vite-plugin-components disabled */'
Original file line number Diff line number Diff line change 1
1
import { Transform } from 'vite'
2
2
import Debug from 'debug'
3
3
import { Context } from '../context'
4
- import { RESOLVER_EXT } from '../constants'
4
+ import { DISABLE_COMMENT , RESOLVER_EXT } from '../constants'
5
5
6
6
const debug = Debug ( 'vite-plugin-components:transform:script' )
7
7
@@ -18,17 +18,20 @@ export function VueScriptTransformer(ctx: Context): Transform {
18
18
&& ! query . type
19
19
} ,
20
20
transform ( { code, path, isBuild } ) {
21
+ if ( code . includes ( DISABLE_COMMENT ) )
22
+ return code
23
+
21
24
const filepath = ctx . normalizePath ( ctx . relative ( path ) )
22
25
debug ( filepath )
23
26
24
- const lines = code . split ( '\n' )
27
+ const lines = code . trim ( ) . split ( '\n' )
25
28
26
29
// tail is the export expression, should insert before it
27
30
const tail = lines . pop ( ) !
28
31
29
32
const entry = isBuild ? 'script' : '__script'
30
33
31
- if ( ! code . includes ( `export default ${ entry } ` ) )
34
+ if ( tail !== `export default ${ entry } ` )
32
35
return code
33
36
34
37
// import a component resolver which is generated by the plugin
You can’t perform that action at this time.
0 commit comments