File tree 3 files changed +25
-1
lines changed
packages/vite/src/node/plugins
3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export function dataURIPlugin(): Plugin {
22
22
} ,
23
23
24
24
resolveId ( id ) {
25
- if ( ! dataUriRE . test ( id ) ) {
25
+ if ( ! id . trimStart ( ) . startsWith ( 'data:' ) ) {
26
26
return
27
27
}
28
28
Original file line number Diff line number Diff line change 1
1
< div class ="plain "> </ div >
2
2
< div class ="base64 "> </ div >
3
+ < div class ="comma "> </ div >
3
4
4
5
< script type ="module ">
5
6
import msg from "data:text/javascript, export default 'hi'"
8
9
import base64Msg from 'data:text/javascript;base64, ZXhwb3J0IGRlZmF1bHQgJ2hpJw=='
9
10
text ( '.base64' , base64Msg )
10
11
12
+ import { comma } from 'comma/foo?number=1,2,3'
13
+ text ( '.comma' , comma )
14
+
11
15
function text ( el , text ) {
12
16
document . querySelector ( el ) . textContent = text
13
17
}
Original file line number Diff line number Diff line change
1
+ import { defineConfig } from 'vite'
2
+
3
+ export default defineConfig ( {
4
+ plugins : [
5
+ {
6
+ name : 'post-plugin' ,
7
+ enforce : 'post' ,
8
+ resolveId ( id ) {
9
+ if ( id . replace ( / \? .* $ / , '' ) === 'comma/foo' ) {
10
+ return id
11
+ }
12
+ } ,
13
+ load ( id ) {
14
+ if ( id . replace ( / \? .* $ / , '' ) === 'comma/foo' ) {
15
+ return `export const comma = 'hi'`
16
+ }
17
+ } ,
18
+ } ,
19
+ ] ,
20
+ } )
You can’t perform that action at this time.
0 commit comments