mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(cli): register packageEntry failed
This commit is contained in:
parent
248c3f08ed
commit
4e793189b6
@ -2,4 +2,4 @@ import { createApp } from 'vue';
|
|||||||
import App from './App';
|
import App from './App';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
|
|
||||||
createApp(App).use(router).mount('#app');
|
window.app = createApp(App).use(router).mount('#app');
|
||||||
|
@ -2,13 +2,16 @@ import { createApp } from 'vue';
|
|||||||
import DemoBlock from './components/DemoBlock';
|
import DemoBlock from './components/DemoBlock';
|
||||||
import DemoSection from './components/DemoSection';
|
import DemoSection from './components/DemoSection';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
|
import { packageEntry } from 'site-mobile-shared';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import '@vant/touch-emulator';
|
import '@vant/touch-emulator';
|
||||||
|
|
||||||
|
window.app = createApp(App)
|
||||||
|
.use(router)
|
||||||
|
.use(packageEntry)
|
||||||
|
.component(DemoBlock.name, DemoBlock)
|
||||||
|
.component(DemoSection.name, DemoSection);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
createApp(App)
|
window.app.mount('#app');
|
||||||
.use(router)
|
|
||||||
.component(DemoBlock.name, DemoBlock)
|
|
||||||
.component(DemoSection.name, DemoSection)
|
|
||||||
.mount('#app');
|
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -17,8 +17,7 @@ type DemoItem = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function genInstall() {
|
function genInstall() {
|
||||||
return `import Vue from 'vue';
|
return `import packageEntry from './package-entry';
|
||||||
import PackageEntry from './package-entry';
|
|
||||||
import './package-style';
|
import './package-style';
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -26,7 +25,7 @@ import './package-style';
|
|||||||
function genImports(demos: DemoItem[]) {
|
function genImports(demos: DemoItem[]) {
|
||||||
return demos
|
return demos
|
||||||
.map(
|
.map(
|
||||||
item =>
|
(item) =>
|
||||||
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
|
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
|
||||||
)
|
)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
@ -34,22 +33,22 @@ function genImports(demos: DemoItem[]) {
|
|||||||
|
|
||||||
function genExports(demos: DemoItem[]) {
|
function genExports(demos: DemoItem[]) {
|
||||||
return `export const demos = {\n ${demos
|
return `export const demos = {\n ${demos
|
||||||
.map(item => item.name)
|
.map((item) => item.name)
|
||||||
.join(',\n ')}\n};`;
|
.join(',\n ')}\n};`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSetName(demos: DemoItem[]) {
|
function getSetName(demos: DemoItem[]) {
|
||||||
return demos
|
return demos
|
||||||
.map(item => `${item.name}.name = 'demo-${item.component}';`)
|
.map((item) => `${item.name}.name = 'demo-${item.component}';`)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
function genConfig(demos: DemoItem[]) {
|
function genConfig(demos: DemoItem[]) {
|
||||||
const vantConfig = getVantConfig();
|
const vantConfig = getVantConfig();
|
||||||
const demoNames = demos.map(item => decamelize(item.name));
|
const demoNames = demos.map((item) => decamelize(item.name));
|
||||||
|
|
||||||
function demoFilter(nav: any[]) {
|
function demoFilter(nav: any[]) {
|
||||||
return nav.filter(group => {
|
return nav.filter((group) => {
|
||||||
group.items = group.items.filter((item: any) =>
|
group.items = group.items.filter((item: any) =>
|
||||||
demoNames.includes(item.path)
|
demoNames.includes(item.path)
|
||||||
);
|
);
|
||||||
@ -73,17 +72,17 @@ function genConfig(demos: DemoItem[]) {
|
|||||||
|
|
||||||
function genCode(components: string[]) {
|
function genCode(components: string[]) {
|
||||||
const demos = components
|
const demos = components
|
||||||
.map(component => ({
|
.map((component) => ({
|
||||||
component,
|
component,
|
||||||
name: pascalize(component),
|
name: pascalize(component),
|
||||||
path: join(SRC_DIR, component, 'demo/index.vue'),
|
path: join(SRC_DIR, component, 'demo/index.vue'),
|
||||||
}))
|
}))
|
||||||
.filter(item => existsSync(item.path));
|
.filter((item) => existsSync(item.path));
|
||||||
|
|
||||||
return `${genInstall()}
|
return `${genInstall()}
|
||||||
${genImports(demos)}
|
${genImports(demos)}
|
||||||
|
|
||||||
Vue.use(PackageEntry);
|
export { packageEntry };
|
||||||
|
|
||||||
${getSetName(demos)}
|
${getSetName(demos)}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user