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