mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
3
node_modules/vitepress/dist/node/build/build.d.ts
generated
vendored
Normal file
3
node_modules/vitepress/dist/node/build/build.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { BuildConfig as ViteBuildOptions } from 'vite';
|
||||
export declare type BuildOptions = Pick<Partial<ViteBuildOptions>, 'root' | 'rollupInputOptions' | 'rollupOutputOptions' | 'rollupPluginVueOptions'>;
|
||||
export declare function build(buildOptions?: BuildOptions): Promise<void>;
|
||||
34
node_modules/vitepress/dist/node/build/build.js
generated
vendored
Normal file
34
node_modules/vitepress/dist/node/build/build.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const bundle_1 = require("./bundle");
|
||||
const config_1 = require("../config");
|
||||
const render_1 = require("./render");
|
||||
async function build(buildOptions = {}) {
|
||||
process.env.NODE_ENV = 'production';
|
||||
const siteConfig = await config_1.resolveConfig(buildOptions.root);
|
||||
try {
|
||||
const [clientResult, , pageToHashMap] = await bundle_1.bundle(siteConfig, buildOptions);
|
||||
console.log('rendering pages...');
|
||||
const appChunk = clientResult.assets.find((chunk) => chunk.type === 'chunk' && chunk.fileName.match(/^app\.\w+\.js$/));
|
||||
const cssChunk = clientResult.assets.find((chunk) => chunk.type === 'asset' && chunk.fileName.endsWith('.css'));
|
||||
// We embed the hash map string into each page directly so that it doesn't
|
||||
// alter the main chunk's hash on every build. It's also embedded as a
|
||||
// string and JSON.parsed from the client because it's faster than embedding
|
||||
// as JS object literal.
|
||||
const hashMapStirng = JSON.stringify(JSON.stringify(pageToHashMap));
|
||||
for (const page of siteConfig.pages) {
|
||||
await render_1.renderPage(siteConfig, page, clientResult, appChunk, cssChunk, pageToHashMap, hashMapStirng);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
await fs_extra_1.default.remove(siteConfig.tempDir);
|
||||
}
|
||||
console.log('done.');
|
||||
}
|
||||
exports.build = build;
|
||||
//# sourceMappingURL=build.js.map
|
||||
1
node_modules/vitepress/dist/node/build/build.js.map
generated
vendored
Normal file
1
node_modules/vitepress/dist/node/build/build.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/node/build/build.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAyB;AACzB,qCAAiC;AAEjC,sCAAyC;AACzC,qCAAqC;AAW9B,KAAK,UAAU,KAAK,CAAC,eAA6B,EAAE;IACzD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAA;IACnC,MAAM,UAAU,GAAG,MAAM,sBAAa,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACzD,IAAI;QACF,MAAM,CAAC,YAAY,EAAE,AAAD,EAAG,aAAa,CAAC,GAAG,MAAM,eAAM,CAClD,UAAU,EACV,YAAY,CACb,CAAA;QACD,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;QAEjC,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CACvC,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CACpD,CAAA;QAEhB,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CACvC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CACtD,CAAA;QAEhB,0EAA0E;QAC1E,sEAAsE;QACtE,4EAA4E;QAC5E,wBAAwB;QACxB,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAA;QAEnE,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,EAAE;YACnC,MAAM,mBAAU,CACd,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,aAAa,CACd,CAAA;SACF;KACF;YAAS;QACR,MAAM,kBAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;KACpC;IACD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AACtB,CAAC;AAxCD,sBAwCC"}
|
||||
4
node_modules/vitepress/dist/node/build/bundle.d.ts
generated
vendored
Normal file
4
node_modules/vitepress/dist/node/build/bundle.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { BuildOptions } from './build';
|
||||
import { SiteConfig } from '../config';
|
||||
import { BuildResult } from 'vite';
|
||||
export declare function bundle(config: SiteConfig, options: BuildOptions): Promise<[BuildResult, BuildResult, Record<string, string>]>;
|
||||
133
node_modules/vitepress/dist/node/build/bundle.js
generated
vendored
Normal file
133
node_modules/vitepress/dist/node/build/bundle.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.bundle = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const slash_1 = __importDefault(require("slash"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const resolver_1 = require("../resolver");
|
||||
const config_1 = require("../config");
|
||||
const markdownToVue_1 = require("../markdownToVue");
|
||||
const vite_1 = require("vite");
|
||||
const hashRE = /\.(\w+)\.js$/;
|
||||
const staticInjectMarkerRE = /\b(const _hoisted_\d+ = \/\*#__PURE__\*\/createStaticVNode)\("(.*)", (\d+)\)/g;
|
||||
const staticStripRE = /__VP_STATIC_START__.*?__VP_STATIC_END__/g;
|
||||
const staticRestoreRE = /__VP_STATIC_(START|END)__/g;
|
||||
const isPageChunk = (chunk) => !!(chunk.type === 'chunk' &&
|
||||
chunk.isEntry &&
|
||||
chunk.facadeModuleId &&
|
||||
chunk.facadeModuleId.endsWith('.md'));
|
||||
// bundles the VitePress app for both client AND server.
|
||||
async function bundle(config, options) {
|
||||
const root = config.root;
|
||||
const userConfig = await config_1.resolveUserConfig(root);
|
||||
const resolver = resolver_1.createResolver(config.themeDir, userConfig);
|
||||
const markdownToVue = markdownToVue_1.createMarkdownToVueRenderFn(root);
|
||||
let isClientBuild = true;
|
||||
const pageToHashMap = Object.create(null);
|
||||
const VitePressPlugin = {
|
||||
name: 'vitepress',
|
||||
resolveId(id) {
|
||||
if (id === resolver_1.SITE_DATA_REQUEST_PATH) {
|
||||
return id;
|
||||
}
|
||||
},
|
||||
async load(id) {
|
||||
if (id === resolver_1.SITE_DATA_REQUEST_PATH) {
|
||||
return `export default ${JSON.stringify(JSON.stringify(config.site))}`;
|
||||
}
|
||||
// compile md into vue src
|
||||
if (id.endsWith('.md')) {
|
||||
const content = await fs_extra_1.default.readFile(id, 'utf-8');
|
||||
// TODO use git timestamp
|
||||
const lastUpdated = (await fs_extra_1.default.stat(id)).mtimeMs;
|
||||
const { vueSrc } = markdownToVue(content, id, lastUpdated);
|
||||
return vueSrc;
|
||||
}
|
||||
},
|
||||
renderChunk(code, chunk) {
|
||||
if (isClientBuild && isPageChunk(chunk)) {
|
||||
// For each page chunk, inject marker for start/end of static strings.
|
||||
// we do this here because in generateBundle the chunks would have been
|
||||
// minified and we won't be able to safely locate the strings.
|
||||
// Using a regexp relies on specific output from Vue compiler core,
|
||||
// which is a reasonable trade-off considering the massive perf win over
|
||||
// a full AST parse.
|
||||
code = code.replace(staticInjectMarkerRE, '$1("__VP_STATIC_START__$2__VP_STATIC_END__", $3)');
|
||||
return code;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
generateBundle(_options, bundle) {
|
||||
// for each .md entry chunk, adjust its name to its correct path.
|
||||
for (const name in bundle) {
|
||||
const chunk = bundle[name];
|
||||
if (isPageChunk(chunk) && isClientBuild) {
|
||||
// record page -> hash relations
|
||||
const hash = chunk.fileName.match(hashRE)[1];
|
||||
const pageName = chunk.fileName.replace(hashRE, '');
|
||||
pageToHashMap[pageName] = hash;
|
||||
// inject another chunk with the content stripped
|
||||
bundle[name + '-lean'] = {
|
||||
...chunk,
|
||||
fileName: chunk.fileName.replace(/\.js$/, '.lean.js'),
|
||||
code: chunk.code.replace(staticStripRE, ``)
|
||||
};
|
||||
// remove static markers from orginal code
|
||||
chunk.code = chunk.code.replace(staticRestoreRE, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
// define custom rollup input
|
||||
// this is a multi-entry build - every page is considered an entry chunk
|
||||
// the loading is done via filename conversion rules so that the
|
||||
// metadata doesn't need to be included in the main chunk.
|
||||
const input = {
|
||||
app: path_1.default.resolve(resolver_1.APP_PATH, 'index.js')
|
||||
};
|
||||
config.pages.forEach((file) => {
|
||||
// page filename conversion
|
||||
// foo/bar.md -> foo_bar.md
|
||||
input[slash_1.default(file).replace(/\//g, '_')] = path_1.default.resolve(root, file);
|
||||
});
|
||||
// resolve options to pass to vite
|
||||
const { rollupInputOptions = {}, rollupOutputOptions = {} } = options;
|
||||
const viteOptions = {
|
||||
...options,
|
||||
base: config.site.base,
|
||||
resolvers: [resolver],
|
||||
outDir: config.outDir,
|
||||
// let rollup-plugin-vue compile .md files as well
|
||||
rollupPluginVueOptions: {
|
||||
include: /\.(vue|md)$/
|
||||
},
|
||||
rollupInputOptions: {
|
||||
...rollupInputOptions,
|
||||
input,
|
||||
// important so that each page chunk and the index export things for each
|
||||
// other
|
||||
preserveEntrySignatures: 'allow-extension',
|
||||
plugins: [VitePressPlugin, ...(rollupInputOptions.plugins || [])]
|
||||
},
|
||||
rollupOutputOptions: {
|
||||
...rollupOutputOptions,
|
||||
chunkFileNames: `common-[hash].js`
|
||||
},
|
||||
silent: !process.env.DEBUG,
|
||||
minify: !process.env.DEBUG
|
||||
};
|
||||
console.log('building client bundle...');
|
||||
const clientResult = await vite_1.build(viteOptions);
|
||||
console.log('building server bundle...');
|
||||
isClientBuild = false;
|
||||
const serverResult = await vite_1.ssrBuild({
|
||||
...viteOptions,
|
||||
outDir: config.tempDir
|
||||
});
|
||||
return [clientResult[0], serverResult[0], pageToHashMap];
|
||||
}
|
||||
exports.bundle = bundle;
|
||||
//# sourceMappingURL=bundle.js.map
|
||||
1
node_modules/vitepress/dist/node/build/bundle.js.map
generated
vendored
Normal file
1
node_modules/vitepress/dist/node/build/bundle.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/node/build/bundle.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,kDAAyB;AACzB,wDAAyB;AACzB,0CAA8E;AAE9E,sCAAyD;AAEzD,oDAA8D;AAC9D,+BAKa;AAEb,MAAM,MAAM,GAAG,cAAc,CAAA;AAC7B,MAAM,oBAAoB,GAAG,+EAA+E,CAAA;AAC5G,MAAM,aAAa,GAAG,0CAA0C,CAAA;AAChE,MAAM,eAAe,GAAG,4BAA4B,CAAA;AAEpD,MAAM,WAAW,GAAG,CAClB,KAAgC,EACmB,EAAE,CACrD,CAAC,CAAC,CACA,KAAK,CAAC,IAAI,KAAK,OAAO;IACtB,KAAK,CAAC,OAAO;IACb,KAAK,CAAC,cAAc;IACpB,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,CACrC,CAAA;AAEH,wDAAwD;AACjD,KAAK,UAAU,MAAM,CAC1B,MAAkB,EAClB,OAAqB;IAErB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;IACxB,MAAM,UAAU,GAAG,MAAM,0BAAiB,CAAC,IA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CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAA;AAC1D,CAAC;AA7HD,wBA6HC"}
|
||||
5
node_modules/vitepress/dist/node/build/render.d.ts
generated
vendored
Normal file
5
node_modules/vitepress/dist/node/build/render.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { SiteConfig } from '../config';
|
||||
import { BuildResult } from 'vite';
|
||||
import { OutputChunk, OutputAsset } from 'rollup';
|
||||
export declare function renderPage(config: SiteConfig, page: string, // foo.md
|
||||
result: BuildResult, appChunk: OutputChunk, cssChunk: OutputAsset, pageToHashMap: Record<string, string>, hashMapStirng: string): Promise<void>;
|
||||
99
node_modules/vitepress/dist/node/build/render.js
generated
vendored
Normal file
99
node_modules/vitepress/dist/node/build/render.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.renderPage = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const config_1 = require("../config");
|
||||
const escape = require('escape-html');
|
||||
async function renderPage(config, page, // foo.md
|
||||
result, appChunk, cssChunk, pageToHashMap, hashMapStirng) {
|
||||
const { createApp } = require(path_1.default.join(config.tempDir, `_assets/app.js`));
|
||||
const { app, router } = createApp();
|
||||
const routePath = `/${page.replace(/\.md$/, '')}`;
|
||||
const siteData = config_1.resolveSiteDataByRoute(config.site, routePath);
|
||||
router.go(routePath);
|
||||
// lazy require server-renderer for production build
|
||||
const content = await require('@vue/server-renderer').renderToString(app);
|
||||
const pageName = page.replace(/\//g, '_');
|
||||
// server build doesn't need hash
|
||||
const pageServerJsFileName = pageName + '.js';
|
||||
// for any initial page load, we only need the lean version of the page js
|
||||
// since the static content is already on the page!
|
||||
const pageHash = pageToHashMap[pageName];
|
||||
const pageClientJsFileName = pageName + `.` + pageHash + '.lean.js';
|
||||
// resolve page data so we can render head tags
|
||||
const { __pageData } = require(path_1.default.join(config.tempDir, `_assets`, pageServerJsFileName));
|
||||
const pageData = JSON.parse(__pageData);
|
||||
const assetPath = `${siteData.base}_assets/`;
|
||||
const preloadLinks = [
|
||||
// resolve imports for index.js + page.md.js and inject script tags for
|
||||
// them as well so we fetch everything as early as possible without having
|
||||
// to wait for entry chunks to parse
|
||||
...resolvePageImports(config, page, result, appChunk),
|
||||
pageClientJsFileName,
|
||||
appChunk.fileName
|
||||
]
|
||||
.map((file) => {
|
||||
return `<link rel="modulepreload" href="${assetPath}${file}">`;
|
||||
})
|
||||
.join('\n ');
|
||||
const html = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="${siteData.lang}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>
|
||||
${pageData.title ? pageData.title + ` | ` : ``}${siteData.title}
|
||||
</title>
|
||||
<meta name="description" content="${siteData.description}">
|
||||
<link rel="stylesheet" href="${assetPath}${cssChunk.fileName}">
|
||||
${preloadLinks}
|
||||
${renderHead(siteData.head)}
|
||||
${renderHead(pageData.frontmatter.head)}
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">${content}</div>
|
||||
<script>__VP_HASH_MAP__ = JSON.parse(${hashMapStirng})</script>
|
||||
<script type="module" async src="${assetPath}${appChunk.fileName}"></script>
|
||||
</body>
|
||||
</html>`.trim();
|
||||
const htmlFileName = path_1.default.join(config.outDir, page.replace(/\.md$/, '.html'));
|
||||
await fs_extra_1.default.ensureDir(path_1.default.dirname(htmlFileName));
|
||||
await fs_extra_1.default.writeFile(htmlFileName, html);
|
||||
}
|
||||
exports.renderPage = renderPage;
|
||||
function resolvePageImports(config, page, result, indexChunk) {
|
||||
// find the page's js chunk and inject script tags for its imports so that
|
||||
// they are start fetching as early as possible
|
||||
const srcPath = path_1.default.resolve(config.root, page);
|
||||
const pageChunk = result.assets.find((chunk) => chunk.type === 'chunk' && chunk.facadeModuleId === srcPath);
|
||||
return Array.from(new Set([...indexChunk.imports, ...pageChunk.imports]));
|
||||
}
|
||||
function renderHead(head) {
|
||||
if (!head || !head.length) {
|
||||
return '';
|
||||
}
|
||||
return head
|
||||
.map(([tag, attrs = {}, innerHTML = '']) => {
|
||||
const openTag = `<${tag}${renderAttrs(attrs)}>`;
|
||||
if (tag !== 'link' && tag !== 'meta') {
|
||||
return `${openTag}${innerHTML}</${tag}>`;
|
||||
}
|
||||
else {
|
||||
return openTag;
|
||||
}
|
||||
})
|
||||
.join('\n ');
|
||||
}
|
||||
function renderAttrs(attrs) {
|
||||
return Object.keys(attrs)
|
||||
.map((key) => {
|
||||
return ` ${key}="${escape(attrs[key])}"`;
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
//# sourceMappingURL=render.js.map
|
||||
1
node_modules/vitepress/dist/node/build/render.js.map
generated
vendored
Normal file
1
node_modules/vitepress/dist/node/build/render.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/node/build/render.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,wDAAyB;AACzB,sCAA8D;AAK9D,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAE9B,KAAK,UAAU,UAAU,CAC9B,MAAkB,EAClB,IAAY,EAAE,SAAS;AACvB,MAAmB,EACnB,QAAqB,EACrB,QAAqB,EACrB,aAAqC,EACrC,aAAqB;IAErB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAA;IAC1E,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;IACnC,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO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