File tree 2 files changed +11
-6
lines changed
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import {
15
15
} from '@vue/component-compiler'
16
16
import { Plugin } from 'rollup'
17
17
import * as path from 'path'
18
- import { parse , SFCDescriptor } from '@vue/component-compiler-utils'
18
+ import { parse , SFCDescriptor , SFCBlock } from '@vue/component-compiler-utils'
19
19
20
20
const hash = require ( 'hash-sum' )
21
21
@@ -133,8 +133,13 @@ export default function VuePlugin(opts: VuePluginOptions = {}): Plugin {
133
133
const ref = parseVuePartRequest ( id )
134
134
if ( ref ) {
135
135
const element = resolveVuePart ( descriptors , ref )
136
- if ( 'src' in element && ref . meta . type !== 'styles' ) {
137
- return path . resolve ( path . dirname ( ref . filename ) , ( element as any ) . src as string )
136
+ const src = ( element as SFCBlock ) . src
137
+ if ( ref . meta . type !== 'styles' && typeof src === 'string' ) {
138
+ if ( src . startsWith ( '.' ) ) {
139
+ return path . resolve ( path . dirname ( ref . filename ) , src as string )
140
+ } else {
141
+ return require . resolve ( src , { paths : [ path . dirname ( ref . filename ) ] } )
142
+ }
138
143
}
139
144
140
145
return id
Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ export interface VuePartRequestCreator {
30
30
}
31
31
32
32
export function createVueFilter (
33
- include : string | undefined ,
34
- exclude : string | undefined
33
+ include : string | string [ ] = [ '*.vue' , '**/*.vue' ] ,
34
+ exclude : string | string [ ] = [ ]
35
35
) : ( file : string ) => boolean {
36
- const filter = createFilter ( include || '**/*.vue' , exclude )
36
+ const filter = createFilter ( include , exclude )
37
37
38
38
return id => filter ( id )
39
39
}
You can’t perform that action at this time.
0 commit comments