chore: update build config

pull/1731/head
tangjinzhou 2020-01-15 19:16:56 +08:00
parent 8785179b22
commit 6186c7e83d
1 changed files with 30 additions and 7 deletions

View File

@ -70,7 +70,12 @@ const i18n = new VueI18n({
const router = new VueRouter({ const router = new VueRouter({
mode: 'history', mode: 'history',
routes: [{ path: '/*', component: Test }], routes: [{
path: '/test',
component: () => import('../components/test/index.vue'),
}, {
path: '/*', component: Test
}],
}); });
const store = new Vuex.Store({ const store = new Vuex.Store({
@ -113,12 +118,14 @@ const renderTemplate = name => {
Tooltip: 'tooltip', // for DemoBox Tooltip: 'tooltip', // for DemoBox
}; };
const demoPaths = fs.readdirSync(path.join(__dirname, `../components/${name}/demo`)); const demoPaths = fs
.readdirSync(path.join(__dirname, `../components/${name}/demo`))
demoPaths.forEach(demoPath => { .map(p => `../components/${name}/demo/${p}`);
const demo = fs const testPaths = fs
.readFileSync(path.join(__dirname, `../components/${name}/demo/${demoPath}`)) .readdirSync(path.join(__dirname, `../components/test`))
.toString(); .map(p => `../components/test/${p}`);
[...demoPaths, ...testPaths].forEach(demoPath => {
const demo = fs.readFileSync(path.join(__dirname, demoPath)).toString();
const componentsInDemo = demo.match(/a-(\w+(-\w+)*)/g) || []; const componentsInDemo = demo.match(/a-(\w+(-\w+)*)/g) || [];
componentsInDemo.forEach(name => { componentsInDemo.forEach(name => {
@ -147,6 +154,22 @@ const renderTemplate = name => {
fs.writeFileSync(OUTPUT_PATH, template); fs.writeFileSync(OUTPUT_PATH, template);
}; };
function fsExistsSync(path) {
try {
fs.accessSync(path, fs.F_OK);
} catch (e) {
return false;
}
return true;
}
if (!fsExistsSync(path.join(__dirname, '../components/test/index.vue'))) {
if (!fsExistsSync(path.join(__dirname, '../components/test'))) {
fs.mkdirSync(path.join(__dirname, '../components/test'));
}
fs.writeFileSync(path.join(__dirname, '../components/test/index.vue'), `<template></template>`);
}
let demoWatcher; let demoWatcher;
chokidar.watch(configPath, { ignoreInitial: true }).on('change', async () => { chokidar.watch(configPath, { ignoreInitial: true }).on('change', async () => {