ITADN

`vp create` mutates custom template `vite.config.ts` and creates duplicate config keys

#1836Openblazeshomida 创建于 2026-06-15
bug
B
blazeshomidacommented
### Describe the bug When creating a project from a custom GitHub template using `vp create`, the CLI appears to mutate the template's existing `vite.config.ts` instead of copying it as-is. My original template has a complete `vite.config.ts` that imports local tooling config modules: ```ts import { defineConfig } from "vite-plus"; import { fmt } from "./tooling/format"; import { lint } from "./tooling/lint"; import { getPlugins } from "./tooling/plugins"; import { tasks } from "./tooling/tasks"; import { test } from "./tooling/test"; export default defineConfig(({ mode }) => { return { server: { port: 3000 }, resolve: { tsconfigPaths: true }, plugins: getPlugins(mode), fmt, lint, test, run: { tasks }, }; }); ``` After running `vp create`, the generated project's `vite.config.ts` is changed to include additional inline `fmt` and `lint` config keys: ```ts import { defineConfig } from "vite-plus"; import { fmt } from "./tooling/format"; import { lint } from "./tooling/lint"; import { getPlugins } from "./tooling/plugins"; import { tasks } from "./tooling/tasks"; import { test } from "./tooling/test"; export default defineConfig(({ mode }) => { return { fmt: {}, lint: { jsPlugins: [{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" }], rules: { "vite-plus/prefer-vite-plus-imports": "error" }, options: { typeAware: true, typeCheck: true }, }, server: { port: 3000 }, resolve: { tsconfigPaths: true }, plugins: getPlugins(mode), fmt, lint, test, run: { tasks }, }; }); ``` This creates duplicate `fmt` and `lint` keys in the returned config object. Expected behavior: when a custom template already provides a `vite.config.ts`, `vp create` should preserve it exactly unless the template explicitly opts into config patching. Actual behavior: `vp create` mutates the existing `vite.config.ts` and adds inline `fmt` / `lint` configuration, causing the generated project to differ from the source template. ### Reproduction https://github.com/blazeshomida/vp-react-start ### Steps to reproduce Run: ```sh vp create github:blazeshomida/vp-react-start ``` Use these options: 1. Target directory: `example-app` 2. Package manager: `pnpm` 3. Coding agent instruction files: `none` 4. Editors: `none` 5. Initialize a git repository: `No` 6. Set up pre-commit hooks: `No` Then inspect the generated `vite.config.ts`. The generated config contains additional inline `fmt` and `lint` keys that were not present in the original template config. ### System Info ```shell $ vp env current VITE+ - The Unified Toolchain for the Web Environment: Version 24.16.0 Source engines.node Source Path /Users/blazeshomida/Developer/projects/crypto-lab/package.json Project Root /Users/blazeshomida/Developer/projects/crypto-lab Tool Paths: node /Users/blazeshomida/.vite-plus/js_runtime/node/24.16.0/bin/node npm /Users/blazeshomida/.vite-plus/js_runtime/node/24.16.0/bin/npm npx /Users/blazeshomida/.vite-plus/js_runtime/node/24.16.0/bin/npx Package Manager: Name pnpm Version 11.5.2 Source packageManager Source Path /Users/blazeshomida/Developer/projects/crypto-lab/package.json Project Root /Users/blazeshomida/Developer/projects/crypto-lab Bin Path /Users/blazeshomida/.vite-plus/package_manager/pnpm/11.5.2/pnpm/bin/pnpm $ vp --version VITE+ - The Unified Toolchain for the Web vp v0.1.24 Local vite-plus: vite-plus v0.1.24 Tools: vite v8.0.16 rolldown v1.0.3 vitest v4.1.8 oxfmt v0.52.0 oxlint v1.67.0 oxlint-tsgolint v0.23.0 tsdown v0.22.1 Environment: Package manager pnpm v11.5.2 Node.js v24.16.0 (engines.node) ``` ### Used Package Manager pnpm ### Logs ```shell $ vp create github:blazeshomida/vp-react-start VITE+ - The Unified Toolchain for the Web ◇ Target directory: example-app ◇ Which package manager would you like to use? pnpm ◇ pnpm@11.6.0 installed ◇ Which coding agent instruction files should Vite+ create? none ◇ Which editors are you using? Writes editor config files to enable recommended extensions and Oxlint/Oxfmt integrations. none ◇ Initialize a git repository with an initial commit? No ◇ Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes? No Generating project… Running: pnpm dlx degit blazeshomida/vp-react-start example-app Packages: +1 + Progress: resolved 1, reused 1, downloaded 0, added 0, done > cloned blazeshomida/vp-react-start#HEAD to example-app ◇ Dependencies installed ◇ Code formatted ◇ Scaffolded example-app • Node 24.16.0 pnpm 11.6.0 ✓ Dependencies installed in 3.8s → Next: cd example-app && vp run Resulting `vite.config.ts` diff: export default defineConfig(({ mode }) => { return { + fmt: {}, + lint: { + jsPlugins: [{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" }], + rules: { "vite-plus/prefer-vite-plus-imports": "error" }, + options: { typeAware: true, typeCheck: true }, + }, server: { port: 3000 }, resolve: { tsconfigPaths: true }, plugins: getPlugins(mode), fmt, lint, test, run: { tasks }, }; }); ``` ### Validations - [x] Read the [Contributing Guidelines](https://github.com/voidzero-dev/vite-plus/blob/main/CONTRIBUTING.md). - [x] Check that there isn't [already an issue](https://github.com/voidzero-dev/vite-plus/issues) for the same bug. - [x] Confirm this is a Vite+ issue and not an upstream issue (Vite, Vitest, tsdown, Rolldown, or Oxc). - [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example).
1 条评论