@@ -798,18 +798,18 @@ In the following example we use a trick to preserve reactivity through the `Vue.
798
798
const config = {
799
799
files: {
800
800
' /main.vue' : {
801
- content : /* <!-- */ `
801
+ getContentData : () => /* <!-- */ `
802
802
<template>
803
803
<pre><b>'url!./circle.svg' -> </b>{{ require('url!./circle.svg') }}</pre>
804
804
<img width="50" height="50" src="~url!./circle.svg" />
805
805
<pre><b>'file!./circle.svg' -> </b>{{ require('file!./circle.svg') }}</pre>
806
- <img width="50" height="50" src="~file!./circle.svg" />
806
+ <img width="50" height="50" src="~file!./circle.svg" /> <br><i>(image failed to load, this is expected since there is nothing behind this url)</i>
807
807
</template>
808
808
` /* --> */ ,
809
809
type: ' .vue' ,
810
810
},
811
811
' /circle.svg' : {
812
- content : /* <!-- */ `
812
+ getContentData : () => /* <!-- */ `
813
813
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
814
814
<circle cx="50" cy="50" r="50" />
815
815
</svg>
@@ -834,10 +834,10 @@ In the following example we use a trick to preserve reactivity through the `Vue.
834
834
throw new Error (` ${ type } not handled by url!` );
835
835
},
836
836
},
837
- handleModule (type , source , path , options ) {
837
+ handleModule (type , getContentData , path , options ) {
838
838
839
839
switch (type) {
840
- case ' .svg' : return source ;
840
+ case ' .svg' : return getContentData ( false ) ;
841
841
default : return undefined ; // let vue3-sfc-loader handle this
842
842
}
843
843
},
@@ -872,10 +872,9 @@ In the following example we use a trick to preserve reactivity through the `Vue.
872
872
path,
873
873
async getContent () {
874
874
875
- const { content , type } = await getFile (path);
876
-
875
+ const { getContentData , type } = await getFile (path);
877
876
return {
878
- content : processContentThroughLoaders (content , path, type, options),
877
+ getContentData : async ( asBinary ) => processContentThroughLoaders (await getContentData (asBinary) , path, type, options),
879
878
type,
880
879
};
881
880
}
@@ -938,7 +937,7 @@ This example use Vue2 because **vue-calendar-picker** is written for Vue2.
938
937
if ( new URL (url).pathname === ' /main.vue' ) {
939
938
940
939
return {
941
- content : /* <!--*/ `
940
+ getContentData : () => /* <!--*/ `
942
941
<template>
943
942
<div>
944
943
<calendar-range locale="EN" :selection="selection" :events="calendarEvents"/>
0 commit comments