@@ -70,7 +70,12 @@ const i18n = new VueI18n({
7070
7171const router = new VueRouter({
7272 mode: 'history',
73- routes: [{ path: '/*', component: Test }],
73+ routes: [{
74+ path: '/test',
75+ component: () => import('../components/test/index.vue'),
76+ }, {
77+ path: '/*', component: Test
78+ }],
7479});
7580
7681const store = new Vuex.Store({
@@ -113,12 +118,14 @@ const renderTemplate = name => {
113118 Tooltip : 'tooltip' , // for DemoBox
114119 } ;
115120
116- const demoPaths = fs . readdirSync ( path . join ( __dirname , `../components/${ name } /demo` ) ) ;
117-
118- demoPaths . forEach ( demoPath => {
119- const demo = fs
120- . readFileSync ( path . join ( __dirname , `../components/${ name } /demo/${ demoPath } ` ) )
121- . toString ( ) ;
121+ const demoPaths = fs
122+ . readdirSync ( path . join ( __dirname , `../components/${ name } /demo` ) )
123+ . map ( p => `../components/${ name } /demo/${ p } ` ) ;
124+ const testPaths = fs
125+ . readdirSync ( path . join ( __dirname , `../components/test` ) )
126+ . map ( p => `../components/test/${ p } ` ) ;
127+ [ ...demoPaths , ...testPaths ] . forEach ( demoPath => {
128+ const demo = fs . readFileSync ( path . join ( __dirname , demoPath ) ) . toString ( ) ;
122129
123130 const componentsInDemo = demo . match ( / a - ( \w + ( - \w + ) * ) / g) || [ ] ;
124131 componentsInDemo . forEach ( name => {
@@ -147,6 +154,22 @@ const renderTemplate = name => {
147154 fs . writeFileSync ( OUTPUT_PATH , template ) ;
148155} ;
149156
157+ function fsExistsSync ( path ) {
158+ try {
159+ fs . accessSync ( path , fs . F_OK ) ;
160+ } catch ( e ) {
161+ return false ;
162+ }
163+ return true ;
164+ }
165+
166+ if ( ! fsExistsSync ( path . join ( __dirname , '../components/test/index.vue' ) ) ) {
167+ if ( ! fsExistsSync ( path . join ( __dirname , '../components/test' ) ) ) {
168+ fs . mkdirSync ( path . join ( __dirname , '../components/test' ) ) ;
169+ }
170+ fs . writeFileSync ( path . join ( __dirname , '../components/test/index.vue' ) , `<template></template>` ) ;
171+ }
172+
150173let demoWatcher ;
151174
152175chokidar . watch ( configPath , { ignoreInitial : true } ) . on ( 'change' , async ( ) => {
0 commit comments