@@ -11,71 +11,66 @@ const watchDir = path.join(__dirname, "./routes");
1111/** @type {import("webpack").Configuration } */
1212const config = {
1313 plugins : [
14- new VirtualUrlPlugin (
15- {
16- routes ( ) {
17- const files = fs . readdirSync ( watchDir ) ;
18- return `
14+ new VirtualUrlPlugin ( {
15+ routes ( ) {
16+ const files = fs . readdirSync ( watchDir ) ;
17+ return `
1918 export const routes = {
2019 ${ files . map ( ( key ) => `${ key . split ( "." ) [ 0 ] } : () => import('./routes/${ key } ')` ) . join ( ",\n" ) }
2120 }
2221 ` ;
23- } ,
24- app : "export const app = 'app'" ,
25- config : {
26- type : ".json" ,
27- source ( ) {
28- return '{"name": "virtual-url-plugin"}' ;
29- }
30- } ,
31- ts : {
32- type : ".ts" ,
33- source ( ) {
34- return `interface Info {
22+ } ,
23+ app : "export const app = 'app'" ,
24+ config : {
25+ type : ".json" ,
26+ source ( ) {
27+ return '{"name": "virtual-url-plugin"}' ;
28+ }
29+ } ,
30+ ts : {
31+ type : ".ts" ,
32+ source ( ) {
33+ return `interface Info {
3534 name: string;
3635 }
3736 export const ts = 'const';` ;
38- }
39- } ,
40- "hello.ts" : "export const hello = 'hello';" ,
41- style : {
42- type : ".css" ,
43- source ( ) {
44- return "body{background-color: powderblue;}" ;
45- }
46- } ,
47- txt : {
48- type : ".txt" ,
49- source ( ) {
50- return "Hello world" ;
51- }
52- } ,
53- "hammer.svg" : {
54- context : "" ,
55- type : ".svg" ,
56- source ( ) {
57- return fs . readFileSync ( path . join ( __dirname , "./file.svg" ) ) ;
58- }
59- } ,
60- "src/components/button.js" :
61- "import { trim } from './utils';export const button = trim('button ');" ,
62- "src/components/table.js" : {
63- context : path . join ( __dirname , "./src/components" ) ,
64- source ( ) {
65- return "import { trim } from './utils';export const table = trim('table ');" ;
66- }
67- } ,
68- "src/components/icon.js" : {
69- context : "auto" ,
70- source ( ) {
71- return "import { trim } from './utils';export const icon = trim('icon ');" ;
72- }
7337 }
7438 } ,
75- {
76- context : "auto"
39+ "hello.ts" : "export const hello = 'hello';" ,
40+ style : {
41+ type : ".css" ,
42+ source ( ) {
43+ return "body{background-color: powderblue;}" ;
44+ }
45+ } ,
46+ txt : {
47+ type : ".txt" ,
48+ source ( ) {
49+ return "Hello world" ;
50+ }
51+ } ,
52+ "hammer.svg" : {
53+ context : "" ,
54+ type : ".svg" ,
55+ source ( ) {
56+ return fs . readFileSync ( path . join ( __dirname , "./file.svg" ) ) ;
57+ }
58+ } ,
59+ "src/components/button.js" :
60+ "import { trim } from './utils';export const button = trim('button ');" ,
61+ "src/components/table.js" : {
62+ context : path . join ( __dirname , "./src/components" ) ,
63+ source ( ) {
64+ return "import { trim } from './utils';export const table = trim('table ');" ;
65+ }
66+ } ,
67+ "src/components/icon.js" : {
68+ context : "auto" ,
69+ source ( ) {
70+ return "import { trim } from './utils';export const icon = trim('icon ');" ;
71+ }
7772 }
78- )
73+ } )
7974 ] ,
8075 experiments : {
8176 css : true
0 commit comments