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 { 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 DemoSection from './components/DemoSection';
|
||||
import { router } from './router';
|
||||
import { packageEntry } from 'site-mobile-shared';
|
||||
import App from './App';
|
||||
import '@vant/touch-emulator';
|
||||
|
||||
window.app = createApp(App)
|
||||
.use(router)
|
||||
.use(packageEntry)
|
||||
.component(DemoBlock.name, DemoBlock)
|
||||
.component(DemoSection.name, DemoSection);
|
||||
|
||||
setTimeout(() => {
|
||||
createApp(App)
|
||||
.use(router)
|
||||
.component(DemoBlock.name, DemoBlock)
|
||||
.component(DemoSection.name, DemoSection)
|
||||
.mount('#app');
|
||||
window.app.mount('#app');
|
||||
}, 0);
|
||||
|
@ -17,8 +17,7 @@ type DemoItem = {
|
||||
};
|
||||
|
||||
function genInstall() {
|
||||
return `import Vue from 'vue';
|
||||
import PackageEntry from './package-entry';
|
||||
return `import packageEntry from './package-entry';
|
||||
import './package-style';
|
||||
`;
|
||||
}
|
||||
@ -26,7 +25,7 @@ import './package-style';
|
||||
function genImports(demos: DemoItem[]) {
|
||||
return demos
|
||||
.map(
|
||||
item =>
|
||||
(item) =>
|
||||
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
|
||||
)
|
||||
.join('\n');
|
||||
@ -34,22 +33,22 @@ function genImports(demos: DemoItem[]) {
|
||||
|
||||
function genExports(demos: DemoItem[]) {
|
||||
return `export const demos = {\n ${demos
|
||||
.map(item => item.name)
|
||||
.map((item) => item.name)
|
||||
.join(',\n ')}\n};`;
|
||||
}
|
||||
|
||||
function getSetName(demos: DemoItem[]) {
|
||||
return demos
|
||||
.map(item => `${item.name}.name = 'demo-${item.component}';`)
|
||||
.map((item) => `${item.name}.name = 'demo-${item.component}';`)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
function genConfig(demos: DemoItem[]) {
|
||||
const vantConfig = getVantConfig();
|
||||
const demoNames = demos.map(item => decamelize(item.name));
|
||||
const demoNames = demos.map((item) => decamelize(item.name));
|
||||
|
||||
function demoFilter(nav: any[]) {
|
||||
return nav.filter(group => {
|
||||
return nav.filter((group) => {
|
||||
group.items = group.items.filter((item: any) =>
|
||||
demoNames.includes(item.path)
|
||||
);
|
||||
@ -73,17 +72,17 @@ function genConfig(demos: DemoItem[]) {
|
||||
|
||||
function genCode(components: string[]) {
|
||||
const demos = components
|
||||
.map(component => ({
|
||||
.map((component) => ({
|
||||
component,
|
||||
name: pascalize(component),
|
||||
path: join(SRC_DIR, component, 'demo/index.vue'),
|
||||
}))
|
||||
.filter(item => existsSync(item.path));
|
||||
.filter((item) => existsSync(item.path));
|
||||
|
||||
return `${genInstall()}
|
||||
${genImports(demos)}
|
||||
|
||||
Vue.use(PackageEntry);
|
||||
export { packageEntry };
|
||||
|
||||
${getSetName(demos)}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user