Skip to content

Commit fc855af

Browse files
authored
feat(cli): bundle only documentation sources (#2480)
The published `vite-plus` package currently copies the entire `docs/` workspace, including VitePress tooling, images, and deployment resources. This PR keeps the existing website source layout—`docs/index.md`, `docs/config/`, and `docs/guide/`—and changes the CLI build to copy every `*.md` file recursively from `docs/`, preserving its relative path. Generated dependency/cache trees and all non-Markdown tooling, assets, data files, and package metadata stay outside the published package. Measured by downloading the actual `vite-plus@0.2.9` tarball from npm, repacking it unchanged as a normalized baseline, and then replacing only its docs with this branch: - npm tarball: 1.05 MB → 516 kB, 538 kB smaller (51.1%) - bundled docs files: 51 → 40 This reduces the published npm package; the native `vp` executable itself is unchanged. 🤖 Generated with Codex
1 parent a252a04 commit fc855af

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

packages/cli/build.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -910,11 +910,6 @@ export default toolchain;
910910
console.log(` Created ./versions (${Object.keys(versions).length} tools)`);
911911
}
912912

913-
/**
914-
* Copy the docs source tree into docs/, preserving relative paths.
915-
* Generated VitePress output and installed dependencies are excluded so the package
916-
* only ships authoring sources and referenced assets.
917-
*/
918913
async function copyBundledDocs() {
919914
console.log('\nCopying bundled docs...');
920915

@@ -926,17 +921,22 @@ async function copyBundledDocs() {
926921
return;
927922
}
928923

929-
const skipPrefixes = ['node_modules', '.vitepress/cache', '.vitepress/dist'];
930924
await rm(docsTargetDir, { recursive: true, force: true });
925+
const skipPrefixes = ['node_modules', '.vitepress/cache', '.vitepress/dist'];
931926
await cp(docsSourceDir, docsTargetDir, {
932927
recursive: true,
933-
filter: (src) => {
934-
const rel = relative(docsSourceDir, src).replaceAll('\\', '/');
935-
return !skipPrefixes.some((prefix) => rel === prefix || rel.startsWith(`${prefix}/`));
928+
filter: (source) => {
929+
const relativePath = relative(docsSourceDir, source).replaceAll('\\', '/');
930+
return (
931+
!skipPrefixes.some(
932+
(prefix) => relativePath === prefix || relativePath.startsWith(`${prefix}/`),
933+
) &&
934+
(statSync(source).isDirectory() || source.endsWith('.md'))
935+
);
936936
},
937937
});
938938

939-
console.log(' Copied docs to docs/ (with paths preserved)');
939+
console.log(' Copied Markdown docs to docs/');
940940
}
941941

942942
async function syncReadmeFromRoot() {

0 commit comments

Comments
 (0)