mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
perf: dynamic import markdown file
This commit is contained in:
parent
e307bfc627
commit
f144a6e2cd
packages/vant-cli
@ -1,12 +1,10 @@
|
||||
import { createApp } from 'vue';
|
||||
import { packageEntry } from 'site-desktop-shared';
|
||||
import App from './App.vue';
|
||||
import DemoPlayground from './components/DemoPlayground.vue';
|
||||
import { router } from './router';
|
||||
|
||||
window.app = createApp(App)
|
||||
.use(router)
|
||||
.use(packageEntry)
|
||||
.component(DemoPlayground.name, DemoPlayground);
|
||||
|
||||
setTimeout(() => {
|
||||
|
@ -79,7 +79,12 @@ function resolveDocuments(components: string[]): DocumentItem[] {
|
||||
|
||||
function genImportDocuments(items: DocumentItem[]) {
|
||||
return items
|
||||
.map((item) => `import ${item.name} from '${normalizePath(item.path)}';`)
|
||||
.map(
|
||||
(item) =>
|
||||
`const ${
|
||||
item.name
|
||||
} = defineAsyncComponent(() => import('${normalizePath(item.path)}'));`
|
||||
)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
@ -102,24 +107,15 @@ function genExportVersion() {
|
||||
return `export const packageVersion = '${getPackageJson().version}';`;
|
||||
}
|
||||
|
||||
function genInstall() {
|
||||
return `import './package-style.less';`;
|
||||
}
|
||||
|
||||
function genExportPackageEntry() {
|
||||
return `export { default as packageEntry } from './package-entry';`;
|
||||
}
|
||||
|
||||
export function genSiteDesktopShared() {
|
||||
const dirs = readdirSync(SRC_DIR);
|
||||
const documents = resolveDocuments(dirs);
|
||||
|
||||
const code = `${genInstall()}
|
||||
const code = `import { defineAsyncComponent } from 'vue';
|
||||
${genImportDocuments(documents)}
|
||||
|
||||
${genVantConfigContent()}
|
||||
|
||||
${genExportPackageEntry()}
|
||||
${genExportConfig()}
|
||||
${genExportDocuments(documents)}
|
||||
${genExportVersion()}
|
||||
|
Loading…
x
Reference in New Issue
Block a user