├── .editorconfig ├── .git-blame-ignore-revs ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml ├── PULL_REQUEST_TEMPLATE.md ├── renovate.json5 └── workflows │ ├── ci.yml │ ├── issue-close-require.yml │ ├── issue-labeled.yml │ ├── lock-closed-issues.yml │ ├── publish.yml │ ├── release-continuous.yml │ ├── release-tag.yml │ └── semantic-pull-request.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── .prettierrc.json ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── eslint.config.js ├── package.json ├── packages ├── plugin-vue-jsx │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── types.ts │ └── tsconfig.json └── plugin-vue │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── build.config.ts │ ├── package.json │ ├── src │ ├── compiler.ts │ ├── handleHotUpdate.ts │ ├── helper.ts │ ├── index.ts │ ├── main.ts │ ├── script.ts │ ├── style.ts │ ├── template.ts │ └── utils │ │ ├── descriptorCache.ts │ │ ├── error.ts │ │ └── query.ts │ └── tsconfig.json ├── playground ├── package.json ├── shims.d.ts ├── ssr-vue │ ├── __tests__ │ │ ├── fixtures │ │ │ └── ssrModuleLoader-bad.js │ │ ├── serve.ts │ │ └── ssr-vue.spec.ts │ ├── dep-import-type │ │ ├── deep │ │ │ └── index.d.ts │ │ └── package.json │ ├── example-external-component │ │ ├── ExampleExternalComponent.vue │ │ ├── index.js │ │ └── package.json │ ├── index.html │ ├── package.json │ ├── prerender.js │ ├── server.js │ ├── src │ │ ├── App.vue │ │ ├── assets │ │ │ ├── button.css │ │ │ ├── fonts │ │ │ │ ├── Inter-Italic.woff │ │ │ │ └── Inter-Italic.woff2 │ │ │ └── logo.png │ │ ├── components │ │ │ ├── Foo.jsx │ │ │ ├── ImportType.vue │ │ │ ├── button.js │ │ │ └── foo.css │ │ ├── entry-client.js │ │ ├── entry-server.js │ │ ├── main.js │ │ ├── pages │ │ │ ├── About.vue │ │ │ ├── External.vue │ │ │ ├── Home.vue │ │ │ └── Store.vue │ │ └── router.js │ ├── vite.config.js │ └── vite.config.noexternal.js ├── tailwind-v3 │ ├── App.vue │ ├── PugTemplate.vue │ ├── __tests__ │ │ └── tailwind.spec.ts │ ├── index.css │ ├── index.html │ ├── package.json │ ├── postcss.config.cts │ ├── tailwind.config.js │ └── vite.config.ts ├── tailwind │ ├── App.vue │ ├── PugTemplate.vue │ ├── __tests__ │ │ └── tailwind.spec.ts │ ├── index.css │ ├── index.html │ ├── package.json │ └── vite.config.ts ├── test-utils.ts ├── tsconfig.json ├── vitestGlobalSetup.ts ├── vitestSetup.ts ├── vue-asset-base │ ├── Main.vue │ ├── __tests__ │ │ └── vue-asset-base.spec.ts │ ├── assets │ │ └── asset.png │ ├── env.d.ts │ ├── index.html │ ├── package.json │ └── vite.config.ts ├── vue-custom-id │ ├── Main.vue │ ├── __tests__ │ │ └── vue-custom-id.spec.ts │ ├── components │ │ └── Foo.vue │ ├── index.html │ ├── package.json │ └── vite.config.ts ├── vue-external │ └── src-import │ │ ├── SrcImport.vue │ │ ├── css.module.css │ │ ├── script.ts │ │ ├── srcImportModuleStyle.vue │ │ ├── srcImportModuleStyle2.vue │ │ ├── srcImportStyle.vue │ │ ├── srcImportStyle2.vue │ │ ├── style.css │ │ ├── style2.css │ │ └── template.html ├── vue-jsx │ ├── Comp.tsx │ ├── Comps.jsx │ ├── OtherExt.tesx │ ├── Query.jsx │ ├── Script.vue │ ├── SrcImport.jsx │ ├── SrcImport.vue │ ├── TsImport.vue │ ├── TsImportFile.ts │ ├── __tests__ │ │ └── vue-jsx.spec.ts │ ├── index.html │ ├── main.jsx │ ├── package.json │ ├── setup-syntax-jsx.vue │ └── vite.config.js ├── vue-legacy │ ├── Main.vue │ ├── __tests__ │ │ └── vue-legacy.spec.ts │ ├── assets │ │ └── asset.png │ ├── env.d.ts │ ├── index.html │ ├── inline.css │ ├── module.vue │ ├── package.json │ └── vite.config.ts ├── vue-lib │ ├── __tests__ │ │ ├── serve.ts │ │ └── vue-lib.spec.ts │ ├── index.html │ ├── package.json │ ├── src-consumer │ │ └── index.ts │ ├── src-lib-css │ │ ├── index.css │ │ └── index.ts │ ├── src-lib │ │ ├── CompA.vue │ │ ├── CompB.vue │ │ └── index.ts │ ├── vite.config.consumer.ts │ ├── vite.config.lib-css.ts │ └── vite.config.lib.ts ├── vue-server-origin │ ├── Main.vue │ ├── __tests__ │ │ └── vue-server-origin.spec.ts │ ├── assets │ │ └── asset.png │ ├── env.d.ts │ ├── index.html │ ├── package.json │ └── vite.config.ts ├── vue-sourcemap │ ├── Css.vue │ ├── EmptyScript.vue │ ├── Js.vue │ ├── Less.vue │ ├── Main.vue │ ├── NoScript.vue │ ├── NoTemplate.vue │ ├── Sass.vue │ ├── SassWithImport.vue │ ├── Ts.vue │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── vue-sourcemap.spec.ts.snap │ │ └── vue-sourcemap.spec.ts │ ├── index.html │ ├── package.json │ ├── postcss.config.js │ ├── sassWithImportImported.sass │ ├── src-import │ │ ├── SrcImport.vue │ │ ├── src-import-imported.sass │ │ ├── src-import.css │ │ └── src-import.sass │ └── vite.config.ts └── vue │ ├── Assets.vue │ ├── AsyncComponent.vue │ ├── CssModules.vue │ ├── CustomBlock.vue │ ├── CustomBlockPlugin.ts │ ├── CustomElement.ce.vue │ ├── DefaultLangs.vue │ ├── ExportTypeProps1.vue │ ├── ExportTypeProps2.vue │ ├── Hmr.vue │ ├── HmrCircularReference.vue │ ├── HmrCircularReferenceFile.d.ts │ ├── HmrTsx.vue │ ├── Main.vue │ ├── Node.vue │ ├── Null.vue │ ├── ParserOptions.vue │ ├── PreProcessors.vue │ ├── PreProcessorsHmr.vue │ ├── ScanDep.vue │ ├── Slotted.vue │ ├── Syntax.vue │ ├── TreeShakeScopedStyle.vue │ ├── TsGeneric.vue │ ├── TsImport.vue │ ├── TsImportFile.ts │ ├── TypeProps.vue │ ├── TypePropsTsx.vue │ ├── Url.vue │ ├── __tests__ │ └── vue.spec.ts │ ├── assets │ ├── asset.png │ └── fragment.svg │ ├── index.html │ ├── lib.js │ ├── package.json │ ├── pre-compiled │ ├── external-cssmodules.vue.js │ ├── external-scoped.vue.js │ ├── external.css │ ├── external.module.css │ ├── foo.vue.js │ └── foo.vue__0.css │ ├── public │ ├── favicon.ico │ └── icon.png │ ├── setup-import-template │ ├── SetupImportTemplate.vue │ └── template.html │ ├── src-import │ ├── SrcImport.vue │ ├── css.module.css │ ├── script.ts │ ├── srcImportModuleStyle.vue │ ├── srcImportModuleStyle2.vue │ ├── srcImportStyle.vue │ ├── srcImportStyle2.vue │ ├── style.css │ ├── style2.css │ └── template.html │ ├── tsconfig.json │ ├── types-aliased.d.ts │ ├── types.ts │ ├── vite-env.d.ts │ ├── vite.config.ts │ ├── worker.vue │ └── workerTest.js ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── scripts ├── patchCJS.ts ├── publishCI.ts ├── release.ts ├── releaseUtils.ts └── tsconfig.json ├── vitest.config.e2e.ts └── vitest.config.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # chore: enable prettier trailing commas (#37) 2 | eef8929c95d8b5cce1385a1d5e60da56a8420c0b 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: "\U0001F41E Bug report" 2 | description: Report an issue 3 | labels: [pending triage] 4 | type: Bug 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thanks for taking the time to fill out this bug report! 10 | - type: checkboxes 11 | id: plugins 12 | attributes: 13 | label: Related plugins 14 | description: Select the plugin which is related 15 | options: 16 | - label: | 17 | [plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) 18 | - label: | 19 | [plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) 20 | - type: textarea 21 | id: bug-description 22 | attributes: 23 | label: Describe the bug 24 | description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks! 25 | placeholder: I am doing ... What I expect is ... What actually happening is ... 26 | validations: 27 | required: true 28 | - type: input 29 | id: reproduction 30 | attributes: 31 | label: Reproduction 32 | description: Please provide a link via [vite.new/vue](https://vite.new/vue) / [vite.new/vue-ts](https://vite.new/vue-ts) or a link to a repo that can reproduce the problem you ran into. `npm create vite@latest` and `npm create vite-extra@latest` (for SSR or library repros) can be used as a starter template. A [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) is required ([Why?](https://antfu.me/posts/why-reproductions-are-required)). If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided after 3 days, it will be auto-closed. 33 | placeholder: Reproduction URL 34 | validations: 35 | required: true 36 | - type: textarea 37 | id: reproduction-steps 38 | attributes: 39 | label: Steps to reproduce 40 | description: Please provide any reproduction steps that may need to be described. E.g. if it happens only when running the dev or build script make sure it's clear which one to use. 41 | placeholder: Run `npm install` followed by `npm run dev` 42 | - type: textarea 43 | id: system-info 44 | attributes: 45 | label: System Info 46 | description: Output of `npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers` 47 | render: shell 48 | placeholder: System, Binaries, Browsers 49 | validations: 50 | required: true 51 | - type: dropdown 52 | id: package-manager 53 | attributes: 54 | label: Used Package Manager 55 | description: Select the used package manager 56 | options: 57 | - npm 58 | - yarn 59 | - pnpm 60 | validations: 61 | required: true 62 | - type: textarea 63 | id: logs 64 | attributes: 65 | label: Logs 66 | description: | 67 | Optional if provided reproduction. Please try not to insert an image but copy paste the log text. 68 | 69 | 1. Run `vite` or `vite build` with the `--debug` flag. 70 | 2. Provide the error log here in the format below. 71 | 72 | ```` 73 |
74 | Click to expand! 75 | 76 | ```shell 77 | // paste the log text here 78 | ``` 79 |
80 | ```` 81 | - type: checkboxes 82 | id: checkboxes 83 | attributes: 84 | label: Validations 85 | description: Before submitting the issue, please make sure you do the following 86 | options: 87 | - label: Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md) 88 | required: true 89 | - label: Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md). 90 | required: true 91 | - label: Read the [docs](https://vitejs.dev/guide). 92 | required: true 93 | - label: Check that there isn't [already an issue](https://github.com/vitejs/vite-plugin-vue/issues) that reports the same bug to avoid creating a duplicate. 94 | required: true 95 | - label: Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to [vuejs/core](https://github.com/vuejs/core) instead. 96 | required: true 97 | - label: Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite-plugin-vue/discussions) or join our [Discord Chat Server](https://chat.vitejs.dev/). 98 | required: true 99 | - label: The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug. 100 | required: true 101 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Discord Chat 4 | url: https://chat.vitejs.dev 5 | about: Ask questions and discuss with other Vite users in real time. 6 | - name: Questions & Discussions 7 | url: https://github.com/vitejs/vite-plugin-vue/discussions 8 | about: Use GitHub discussions for message-board style questions and discussions. 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: "\U0001F680 New feature proposal" 2 | description: Propose a new feature 3 | labels: ["pending triage"] 4 | type: Feature 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thanks for your interest in the project and taking the time to fill out this feature report! 10 | - type: checkboxes 11 | id: plugins 12 | attributes: 13 | label: Related plugins 14 | description: Select the plugin which is related 15 | options: 16 | - label: | 17 | [plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) 18 | - label: | 19 | [plugin-vue-jsx](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) 20 | - type: textarea 21 | id: feature-description 22 | attributes: 23 | label: Description 24 | description: "Clear and concise description of the problem. Please make the reason and usecases as detailed as possible. If you intend to submit a PR for this issue, tell us in the description. Thanks!" 25 | placeholder: As a developer using Vite I want [goal / wish] so that [benefit]. 26 | validations: 27 | required: true 28 | - type: textarea 29 | id: suggested-solution 30 | attributes: 31 | label: Suggested solution 32 | description: "In module [xy] we could provide following implementation..." 33 | validations: 34 | required: true 35 | - type: textarea 36 | id: alternative 37 | attributes: 38 | label: Alternative 39 | description: Clear and concise description of any alternative solutions or features you've considered. 40 | - type: textarea 41 | id: additional-context 42 | attributes: 43 | label: Additional context 44 | description: Any other context or screenshots about the feature request here. 45 | - type: checkboxes 46 | id: checkboxes 47 | attributes: 48 | label: Validations 49 | description: Before submitting the issue, please make sure you do the following 50 | options: 51 | - label: Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md) 52 | required: true 53 | - label: Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md). 54 | required: true 55 | - label: Read the [docs](https://vitejs.dev/guide). 56 | required: true 57 | - label: Check that there isn't already an issue that request the same feature to avoid creating a duplicate. 58 | required: true 59 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Description 4 | 5 | 6 | 7 | ### Additional context 8 | 9 | 10 | 11 | --- 12 | 13 | ### What is the purpose of this pull request? 14 | 15 | - [ ] Bug fix 16 | - [ ] New Feature 17 | - [ ] Documentation update 18 | - [ ] Other 19 | 20 | ### Before submitting the PR, please make sure you do the following 21 | 22 | - [ ] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md). 23 | - [ ] Read the [Pull Request Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md#pull-request-guidelines) and follow the [PR Title Convention](https://github.com/vitejs/vite/blob/main/.github/commit-convention.md). 24 | - [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate. 25 | - [ ] Provide a description in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `fixes #123`). 26 | - [ ] Ideally, include relevant tests that fail without this PR but pass with it. 27 | -------------------------------------------------------------------------------- /.github/renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["config:base", "schedule:weekly", "group:allNonMajor"], 3 | "labels": ["dependencies"], 4 | "ignorePaths": ["**/__tests__/**"], 5 | "pin": false, 6 | "rangeStrategy": "bump", 7 | "packageRules": [ 8 | { 9 | "depTypeList": ["peerDependencies"], 10 | "enabled": false, 11 | }, 12 | { 13 | groupName: "upstream", 14 | matchPackageNames: ["vite"], 15 | matchPackagePrefixes: ["rollup", "@rollup", "@vitejs"], 16 | }, 17 | { 18 | groupName: "prettier", 19 | matchPackageNames: ["prettier"], 20 | }, 21 | { 22 | "matchDepTypes": ["action"], 23 | "excludePackagePrefixes": ["actions/", "github/"], 24 | "pinDigests": true, 25 | }, 26 | ], 27 | "ignoreDeps": [ 28 | // manually bumping 29 | "node", 30 | 31 | // breaking changes 32 | "kill-port", // `kill-port:^2.0.0 has perf issues (#8392) 33 | ], 34 | } 35 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | env: 4 | # 7 GiB by default on GitHub, setting to 6 GiB 5 | # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources 6 | NODE_OPTIONS: --max-old-space-size=6144 7 | # install playwright binary manually (because pnpm only runs install script once) 8 | PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" 9 | # Vitest auto retry on flaky segfault 10 | VITEST_SEGFAULT_RETRY: 3 11 | 12 | permissions: {} 13 | 14 | on: 15 | push: 16 | branches: 17 | - main 18 | - release/* 19 | - feat/* 20 | - fix/* 21 | - perf/* 22 | - v1 23 | - v2 24 | - v2.* 25 | - v3.* 26 | pull_request: 27 | workflow_dispatch: 28 | 29 | concurrency: 30 | group: ${{ github.workflow }}-${{ github.event.number || github.sha }} 31 | cancel-in-progress: true 32 | 33 | jobs: 34 | build: 35 | timeout-minutes: 20 36 | runs-on: ${{ matrix.os }} 37 | strategy: 38 | matrix: 39 | os: [ubuntu-latest] 40 | node_version: [18, 20] 41 | include: 42 | # Active LTS + other OS 43 | - os: macos-latest 44 | node_version: 20 45 | - os: windows-latest 46 | node_version: 20 47 | fail-fast: false 48 | 49 | name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}" 50 | steps: 51 | - name: Checkout 52 | uses: actions/checkout@v4 53 | 54 | - name: Install pnpm 55 | uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 56 | 57 | - name: Set node version to ${{ matrix.node_version }} 58 | uses: actions/setup-node@v4 59 | with: 60 | node-version: ${{ matrix.node_version }} 61 | cache: "pnpm" 62 | 63 | - name: Install deps 64 | run: pnpm install 65 | 66 | # Install playwright's binary under custom directory to cache 67 | - name: Set Playwright path (non-windows) 68 | if: runner.os != 'Windows' 69 | run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV 70 | - name: Set Playwright path (windows) 71 | if: runner.os == 'Windows' 72 | run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV 73 | 74 | - name: Cache Playwright's binary 75 | uses: actions/cache@v4 76 | with: 77 | # Playwright removes unused browsers automatically 78 | # So does not need to add playwright version to key 79 | key: ${{ runner.os }}-playwright-bin-v1 80 | path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }} 81 | 82 | - name: Install Playwright 83 | # does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved 84 | run: pnpm playwright install chromium 85 | 86 | - name: Build 87 | run: pnpm run build 88 | 89 | - name: Test serve 90 | run: pnpm run test-serve 91 | 92 | - name: Test build 93 | run: pnpm run test-build 94 | 95 | lint: 96 | if: github.repository == 'vitejs/vite-plugin-vue' 97 | timeout-minutes: 10 98 | runs-on: ubuntu-latest 99 | name: "Lint: node-LTS, ubuntu-latest" 100 | steps: 101 | - uses: actions/checkout@v4 102 | with: 103 | fetch-depth: 0 104 | 105 | - name: Install pnpm 106 | uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 107 | 108 | - name: Set node version to LTS 109 | uses: actions/setup-node@v4 110 | with: 111 | node-version: lts/* 112 | cache: "pnpm" 113 | 114 | - name: Install deps 115 | run: pnpm install 116 | 117 | - name: Build 118 | run: pnpm run build 119 | 120 | - name: Lint 121 | run: pnpm run lint 122 | 123 | - name: Check formatting 124 | run: pnpm prettier --check . 125 | 126 | - name: Typecheck 127 | run: pnpm run typecheck 128 | -------------------------------------------------------------------------------- /.github/workflows/issue-close-require.yml: -------------------------------------------------------------------------------- 1 | name: Issue Close Require 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" 6 | 7 | jobs: 8 | close-issues: 9 | if: github.repository == 'vitejs/vite-plugin-vue' 10 | runs-on: ubuntu-latest 11 | permissions: 12 | issues: write # for actions-cool/issues-helper to update issues 13 | pull-requests: write # for actions-cool/issues-helper to update PRs 14 | steps: 15 | - name: need reproduction 16 | uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3 17 | with: 18 | actions: "close-issues" 19 | token: ${{ secrets.GITHUB_TOKEN }} 20 | labels: "need reproduction" 21 | inactive-day: 3 22 | -------------------------------------------------------------------------------- /.github/workflows/issue-labeled.yml: -------------------------------------------------------------------------------- 1 | name: Issue Labeled 2 | 3 | on: 4 | issues: 5 | types: [labeled] 6 | 7 | jobs: 8 | reply-labeled: 9 | if: github.repository == 'vitejs/vite-plugin-vue' 10 | runs-on: ubuntu-latest 11 | permissions: 12 | issues: write # for actions-cool/issues-helper to update issues 13 | pull-requests: write # for actions-cool/issues-helper to update PRs 14 | steps: 15 | - name: contribution welcome 16 | if: github.event.label.name == 'contribution welcome' || github.event.label.name == 'help wanted' 17 | uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3 18 | with: 19 | actions: "create-comment, remove-labels" 20 | token: ${{ secrets.GITHUB_TOKEN }} 21 | issue-number: ${{ github.event.issue.number }} 22 | body: | 23 | Hello @${{ github.event.issue.user.login }}. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it! 24 | labels: "pending triage, need reproduction" 25 | 26 | - name: remove pending 27 | if: (github.event.label.name == 'enhancement' || contains(github.event.label.description, '(priority)')) && contains(github.event.issue.labels.*.name, 'pending triage') 28 | uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3 29 | with: 30 | actions: "remove-labels" 31 | token: ${{ secrets.GITHUB_TOKEN }} 32 | issue-number: ${{ github.event.issue.number }} 33 | labels: "pending triage" 34 | 35 | - name: need reproduction 36 | if: github.event.label.name == 'need reproduction' 37 | uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3 38 | with: 39 | actions: "create-comment, remove-labels" 40 | token: ${{ secrets.GITHUB_TOKEN }} 41 | issue-number: ${{ github.event.issue.number }} 42 | body: | 43 | Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository or [StackBlitz](https://vite.new). Issues marked with `need reproduction` will be closed if they have no activity within 3 days. 44 | labels: "pending triage" 45 | -------------------------------------------------------------------------------- /.github/workflows/lock-closed-issues.yml: -------------------------------------------------------------------------------- 1 | name: Lock Closed Issues 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" 6 | 7 | permissions: 8 | issues: write 9 | 10 | jobs: 11 | action: 12 | if: github.repository == 'vitejs/vite-plugin-vue' 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5 16 | with: 17 | github-token: ${{ secrets.GITHUB_TOKEN }} 18 | issue-inactive-days: "14" 19 | #issue-comment: | 20 | # This issue has been locked since it has been closed for more than 14 days. 21 | # 22 | # If you have found a concrete bug or regression related to it, please open a new [bug report](https://github.com/vitejs/vite-plugin-vue/issues/new/choose) with a reproduction against the latest Vite version. If you have any other comments you should join the chat at [Vite Land](https://chat.vitejs.dev) or create a new [discussion](https://github.com/vitejs/vite-plugin-vue/discussions). 23 | issue-lock-reason: "" 24 | process-only: "issues" 25 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish Package 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 7 | - "plugin-*" # Push events to matching plugin-*, i.e. plugin-(vue|vue-jsx|react|legacy)@1.0.0 8 | - "create-vite*" # # Push events to matching create-vite*, i.e. create-vite@1.0.0 9 | 10 | jobs: 11 | publish: 12 | # prevents this action from running on forks 13 | if: github.repository == 'vitejs/vite-plugin-vue' 14 | runs-on: ubuntu-latest 15 | permissions: 16 | contents: read 17 | id-token: write 18 | environment: Release 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | 23 | - name: Install pnpm 24 | uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 25 | 26 | - name: Set node version to LTS 27 | uses: actions/setup-node@v4 28 | with: 29 | node-version: lts/* 30 | registry-url: https://registry.npmjs.org/ 31 | cache: "pnpm" 32 | 33 | - name: Install deps 34 | run: pnpm install 35 | env: 36 | PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" 37 | 38 | # https://github.com/npm/cli/pull/6978 39 | - name: Pin npm 40 | run: npm i -g npm@10.2.4 41 | 42 | - name: Publish package 43 | run: pnpm run ci-publish ${{ github.ref_name }} 44 | env: 45 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 46 | -------------------------------------------------------------------------------- /.github/workflows/release-continuous.yml: -------------------------------------------------------------------------------- 1 | name: Publish Any Commit 2 | on: [push, pull_request] 3 | 4 | permissions: {} 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - name: Checkout code 12 | uses: actions/checkout@v4 13 | 14 | - name: Install pnpm 15 | uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 16 | 17 | - uses: actions/setup-node@v4 18 | with: 19 | node-version: lts/* 20 | cache: pnpm 21 | 22 | - name: Install dependencies 23 | run: pnpm install 24 | 25 | - name: Build 26 | run: pnpm build 27 | 28 | - name: Publish 29 | run: pnpm dlx pkg-pr-new@0.0 publish --pnpm --compact './packages/*' 30 | -------------------------------------------------------------------------------- /.github/workflows/release-tag.yml: -------------------------------------------------------------------------------- 1 | name: Add GitHub Release Tag 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 7 | - "plugin-*" # Push events to matching plugin-*, i.e. plugin-(vue|vue-jsx|react|legacy)@1.0.0 8 | - "create-vite*" # # Push events to matching create-vite*, i.e. create-vite@1.0.0 9 | 10 | # $GITHUB_REF_NAME - https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables 11 | 12 | jobs: 13 | release: 14 | if: github.repository == 'vitejs/vite-plugin-vue' 15 | runs-on: ubuntu-latest 16 | permissions: 17 | contents: write # for yyx990803/release-tag to create a release tag 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Get pkgName for tag 22 | id: tag 23 | run: | 24 | # matching v2.0.0 / v2.0.0-beta.8 etc 25 | if [[ $GITHUB_REF_NAME =~ ^v.+ ]]; then 26 | pkgName="vite" 27 | else 28 | # `%@*` truncates @ and version number from the right side. 29 | # https://stackoverflow.com/questions/9532654/expression-after-last-specific-character 30 | pkgName=${GITHUB_REF_NAME%@*} 31 | fi 32 | 33 | echo "::set-output name=pkgName::$pkgName" 34 | 35 | - name: Create Release for Tag 36 | id: release_tag 37 | uses: yyx990803/release-tag@master 38 | env: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | with: 41 | tag_name: ${{ github.ref }} 42 | body: | 43 | Please refer to [CHANGELOG.md](https://github.com/vitejs/vite-plugin-vue/blob/${{ github.ref_name }}/packages/${{ steps.tag.outputs.pkgName }}/CHANGELOG.md) for details. 44 | -------------------------------------------------------------------------------- /.github/workflows/semantic-pull-request.yml: -------------------------------------------------------------------------------- 1 | name: Semantic Pull Request 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | - edited 8 | - synchronize 9 | 10 | jobs: 11 | main: 12 | if: github.repository == 'vitejs/vite-plugin-vue' 13 | runs-on: ubuntu-latest 14 | name: Semantic Pull Request 15 | permissions: 16 | pull-requests: read 17 | steps: 18 | - name: Validate PR title 19 | uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5 20 | with: 21 | subjectPattern: ^(?![A-Z]).+$ 22 | subjectPatternError: | 23 | The subject "{subject}" found in the pull request title "{title}" 24 | didn't match the configured pattern. Please ensure that the subject 25 | doesn't start with an uppercase character. 26 | env: 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | !**/glob-import/dir/node_modules 2 | .DS_Store 3 | .idea 4 | *.cpuprofile 5 | *.local 6 | *.log 7 | /.vscode/ 8 | /packages/vite/LICENSE 9 | dist 10 | dist-ssr 11 | explorations 12 | node_modules 13 | playground-temp 14 | temp 15 | TODOs.md 16 | .eslintcache 17 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | hoist-pattern[]=postcss 2 | hoist-pattern[]=pug # playground/vue > @vue/compiler-sfc 3 | hoist-pattern[]=ts-node # playground/tailwind 4 | strict-peer-dependencies=false 5 | shell-emulator=true 6 | auto-install-peers=false 7 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | packages/*/CHANGELOG.md 2 | playground-temp/ 3 | dist/ 4 | temp/ 5 | LICENSE.md 6 | pnpm-lock.yaml 7 | pnpm-workspace.yaml 8 | playground/tsconfig-json-load-error/has-error/tsconfig.json 9 | playground/html/invalid.html 10 | playground/html/valid.html 11 | playground/worker/classic-worker.js 12 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "tabWidth": 2, 4 | "singleQuote": true, 5 | "printWidth": 80, 6 | "trailingComma": "all", 7 | "overrides": [ 8 | { 9 | "files": ["*.json5"], 10 | "options": { 11 | "singleQuote": false, 12 | "quoteProps": "preserve" 13 | } 14 | }, 15 | { 16 | "files": ["*.yml"], 17 | "options": { 18 | "singleQuote": false 19 | } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code Of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, political party, or sexual identity and orientation. Note, however, that religion, political party, or other ideological affiliation provide no exemptions for the behavior we outline as unacceptable in this Code of Conduct. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | - Using welcoming and inclusive language 12 | - Being respectful of differing viewpoints and experiences 13 | - Gracefully accepting constructive criticism 14 | - Focusing on what is best for the community 15 | - Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | - The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | - Trolling, insulting/derogatory comments, and personal or political attacks 21 | - Public or private harassment 22 | - Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | - Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team by DM at [Vite Land](https://chat.vitejs.dev). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 44 | 45 | [homepage]: https://www.contributor-covenant.org 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Vite logo 4 | 5 |

6 |
7 |

8 | npm package 9 | node compatibility 10 | build status 11 | discord chat 12 |

13 |
14 | 15 | # Vite Plugin Vue 16 | 17 | See [`@vitejs/plugin-vue` documentation](packages/plugin-vue/README.md) and [`@vitejs/plugin-vue-jsx` documentation](packages/plugin-vue-jsx/README.md) 18 | 19 | ## Packages 20 | 21 | | Package | Version (click for changelogs) | 22 | | ------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- | 23 | | [@vitejs/plugin-vue](packages/plugin-vue) | [![plugin-vue version](https://img.shields.io/npm/v/@vitejs/plugin-vue.svg?label=%20)](packages/plugin-vue/CHANGELOG.md) | 24 | | [@vitejs/plugin-vue-jsx](packages/plugin-vue-jsx) | [![plugin-vue-jsx version](https://img.shields.io/npm/v/@vitejs/plugin-vue-jsx.svg?label=%20)](packages/plugin-vue-jsx/CHANGELOG.md) | 25 | 26 | ## License 27 | 28 | [MIT](LICENSE). 29 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | import { builtinModules } from 'node:module' 3 | import eslint from '@eslint/js' 4 | import tseslint from 'typescript-eslint' 5 | import nodePlugin from 'eslint-plugin-n' 6 | import * as regexpPlugin from 'eslint-plugin-regexp' 7 | import importPlugin, { createNodeResolver } from 'eslint-plugin-import-x' 8 | import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript' 9 | 10 | export default tseslint.config( 11 | eslint.configs.recommended, 12 | ...tseslint.configs.recommended, 13 | nodePlugin.configs['flat/recommended'], 14 | regexpPlugin.configs['flat/recommended'], 15 | { ignores: ['**/dist', '**/playground-temp', '**/temp'] }, 16 | { 17 | plugins: { 18 | import: importPlugin, 19 | }, 20 | settings: { 21 | 'import-x/resolver-next': [ 22 | createNodeResolver(), 23 | createTypeScriptImportResolver(), 24 | ], 25 | }, 26 | rules: { 27 | eqeqeq: ['warn', 'always', { null: 'never' }], 28 | 'no-empty': ['warn', { allowEmptyCatch: true }], 29 | 'no-useless-escape': 'off', 30 | 'prefer-const': ['warn', { destructuring: 'all' }], 31 | 32 | 'n/no-process-exit': 'off', 33 | 'n/no-missing-import': [ 34 | 'error', 35 | { 36 | allowModules: ['types', 'estree', 'less', 'sass', 'stylus'], 37 | tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], 38 | }, 39 | ], 40 | 'n/no-missing-require': [ 41 | 'error', 42 | { 43 | // for try-catching yarn pnp 44 | allowModules: ['pnpapi', 'vite'], 45 | tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], 46 | }, 47 | ], 48 | 'n/no-extraneous-import': [ 49 | 'error', 50 | { allowModules: ['vite', 'less', 'sass', 'vitest', 'unbuild'] }, 51 | ], 52 | 'n/no-extraneous-require': ['error', { allowModules: ['vite'] }], 53 | 'n/no-deprecated-api': 'off', 54 | 'n/no-unpublished-import': 'off', 55 | 'n/no-unpublished-require': 'off', 56 | 'n/no-unsupported-features/es-syntax': 'off', 57 | 58 | '@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR 59 | '@typescript-eslint/explicit-module-boundary-types': [ 60 | 'error', 61 | { allowArgumentsExplicitlyTypedAsAny: true }, 62 | ], 63 | '@typescript-eslint/no-empty-function': [ 64 | 'error', 65 | { allow: ['arrowFunctions'] }, 66 | ], 67 | '@typescript-eslint/no-empty-object-type': 'off', 68 | '@typescript-eslint/no-explicit-any': 'off', // maybe we should turn this on in a new PR 69 | '@typescript-eslint/no-inferrable-types': 'off', 70 | '@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR 71 | '@typescript-eslint/no-require-imports': 'off', 72 | '@typescript-eslint/consistent-type-imports': [ 73 | 'error', 74 | { prefer: 'type-imports' }, 75 | ], 76 | 77 | 'import/no-nodejs-modules': [ 78 | 'error', 79 | { allow: builtinModules.map((mod) => `node:${mod}`) }, 80 | ], 81 | 'import/no-duplicates': 'error', 82 | 'import/order': 'error', 83 | 'sort-imports': [ 84 | 'error', 85 | { 86 | ignoreCase: false, 87 | ignoreDeclarationSort: true, 88 | ignoreMemberSort: false, 89 | memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], 90 | allowSeparatedGroups: false, 91 | }, 92 | ], 93 | 94 | 'regexp/no-contradiction-with-assertion': 'error', 95 | }, 96 | }, 97 | { 98 | files: ['packages/**'], 99 | ignores: ['**/__tests__/**'], 100 | rules: { 101 | 'no-restricted-globals': ['error', 'require', '__dirname', '__filename'], 102 | }, 103 | }, 104 | { 105 | files: ['**/build.config.ts'], 106 | rules: { 107 | 'no-undef': 'off', 108 | 'n/no-missing-import': 'off', 109 | '@typescript-eslint/explicit-module-boundary-types': 'off', 110 | }, 111 | }, 112 | { 113 | files: ['playground/**'], 114 | rules: { 115 | 'n/no-extraneous-import': 'off', 116 | 'n/no-extraneous-require': 'off', 117 | 'n/no-missing-import': 'off', 118 | 'n/no-missing-require': 'off', 119 | // engine field doesn't exist in playgrounds 120 | 'n/no-unsupported-features/es-builtins': [ 121 | 'error', 122 | { 123 | version: '^18.0.0 || >=20.0.0', 124 | }, 125 | ], 126 | 'n/no-unsupported-features/node-builtins': [ 127 | 'error', 128 | { 129 | version: '^18.0.0 || >=20.0.0', 130 | }, 131 | ], 132 | '@typescript-eslint/explicit-module-boundary-types': 'off', 133 | }, 134 | }, 135 | { 136 | files: ['playground/**'], 137 | ignores: ['**/__tests__/**'], 138 | rules: { 139 | 'no-undef': 'off', 140 | 'no-empty': 'off', 141 | 'no-constant-condition': 'off', 142 | '@typescript-eslint/no-empty-function': 'off', 143 | }, 144 | }, 145 | { 146 | name: 'tests', 147 | files: ['**/__tests__/**/*'], 148 | rules: { 149 | 'n/no-extraneous-import': 'off', 150 | 'n/no-unsupported-features/node-builtins': [ 151 | 'error', 152 | { 153 | version: '^18.0.0 || >=20.0.0', 154 | allowExperimental: true, 155 | }, 156 | ], 157 | }, 158 | }, 159 | { 160 | files: ['*.js', '*.mjs', '*.cjs'], 161 | rules: { 162 | '@typescript-eslint/explicit-module-boundary-types': 'off', 163 | }, 164 | }, 165 | { 166 | files: ['*.d.ts'], 167 | rules: { 168 | '@typescript-eslint/triple-slash-reference': 'off', 169 | }, 170 | }, 171 | ) 172 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vitejs/vite-plugin-vue-monorepo", 3 | "private": true, 4 | "type": "module", 5 | "engines": { 6 | "node": "^18.0.0 || >=20.0.0" 7 | }, 8 | "homepage": "https://github.com/vitejs/vite-plugin-vue/", 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/vitejs/vite-plugin-vue.git" 12 | }, 13 | "keywords": [ 14 | "frontend", 15 | "hmr", 16 | "dev-server", 17 | "build-tool", 18 | "vite", 19 | "vue" 20 | ], 21 | "scripts": { 22 | "preinstall": "npx only-allow pnpm", 23 | "postinstall": "simple-git-hooks", 24 | "format": "prettier --write --cache .", 25 | "lint": "eslint --cache .", 26 | "typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit", 27 | "test": "pnpm test-serve && pnpm test-build", 28 | "test-serve": "vitest run -c vitest.config.e2e.ts", 29 | "test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts", 30 | "test-build-without-plugin-commonjs": "VITE_TEST_WITHOUT_PLUGIN_COMMONJS=1 pnpm test-build", 31 | "debug-serve": "VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts", 32 | "debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts", 33 | "build": "pnpm -r --filter='./packages/*' run build", 34 | "dev": "pnpm -r --parallel --filter='./packages/*' run dev", 35 | "release": "tsx scripts/release.ts", 36 | "ci-publish": "tsx scripts/publishCI.ts" 37 | }, 38 | "devDependencies": { 39 | "@babel/types": "^7.27.1", 40 | "@eslint/js": "^9.27.0", 41 | "@types/babel__core": "^7.20.5", 42 | "@types/convert-source-map": "^2.0.3", 43 | "@types/debug": "^4.1.12", 44 | "@types/fs-extra": "^11.0.4", 45 | "@types/node": "^22.15.19", 46 | "@vitejs/release-scripts": "^1.5.0", 47 | "conventional-changelog-cli": "^5.0.0", 48 | "eslint": "^9.27.0", 49 | "eslint-import-resolver-typescript": "^4.3.5", 50 | "eslint-plugin-import-x": "^4.12.2", 51 | "eslint-plugin-n": "^17.18.0", 52 | "eslint-plugin-regexp": "^2.7.0", 53 | "execa": "^9.5.3", 54 | "fs-extra": "^11.3.0", 55 | "lint-staged": "^16.0.0", 56 | "picocolors": "^1.1.1", 57 | "playwright-chromium": "^1.52.0", 58 | "prettier": "3.5.3", 59 | "rollup": "^4.40.2", 60 | "simple-git-hooks": "^2.13.0", 61 | "tsx": "^4.19.4", 62 | "typescript": "^5.8.3", 63 | "typescript-eslint": "^8.32.1", 64 | "unbuild": "3.5.0", 65 | "vite": "catalog:", 66 | "vitest": "^3.1.4", 67 | "vue": "catalog:" 68 | }, 69 | "simple-git-hooks": { 70 | "pre-commit": "pnpm exec lint-staged --concurrent false" 71 | }, 72 | "lint-staged": { 73 | "*": [ 74 | "prettier --write --cache --ignore-unknown" 75 | ], 76 | "packages/*/{src,types}/**/*.ts": [ 77 | "eslint --cache --fix" 78 | ], 79 | "packages/**/*.d.ts": [ 80 | "eslint --cache --fix" 81 | ], 82 | "playground/**/__tests__/**/*.ts": [ 83 | "eslint --cache --fix" 84 | ] 85 | }, 86 | "packageManager": "pnpm@10.11.0", 87 | "pnpm": { 88 | "overrides": { 89 | "@vitejs/plugin-vue": "workspace:*" 90 | }, 91 | "ignoredBuiltDependencies": [ 92 | "@parcel/watcher", 93 | "core-js", 94 | "esbuild" 95 | ], 96 | "onlyBuiltDependencies": [ 97 | "playwright-chromium", 98 | "simple-git-hooks" 99 | ] 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /packages/plugin-vue-jsx/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/plugin-vue-jsx/README.md: -------------------------------------------------------------------------------- 1 | # @vitejs/plugin-vue-jsx [![npm](https://img.shields.io/npm/v/@vitejs/plugin-vue-jsx.svg)](https://npmjs.com/package/@vitejs/plugin-vue-jsx) 2 | 3 | Provides Vue 3 JSX & TSX support with HMR. 4 | 5 | ```js 6 | // vite.config.js 7 | import vueJsx from '@vitejs/plugin-vue-jsx' 8 | 9 | export default { 10 | plugins: [ 11 | vueJsx({ 12 | // options are passed on to @vue/babel-plugin-jsx 13 | }), 14 | ], 15 | } 16 | ``` 17 | 18 | ## Options 19 | 20 | ### include 21 | 22 | Type: `(string | RegExp)[] | string | RegExp | null` 23 | 24 | Default: `/\.[jt]sx$/` 25 | 26 | A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on. 27 | 28 | ### exclude 29 | 30 | Type: `(string | RegExp)[] | string | RegExp | null` 31 | 32 | Default: `undefined` 33 | 34 | A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files to be ignored by the plugin. 35 | 36 | > See [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next) for other options. 37 | 38 | ### defineComponentName 39 | 40 | Type: `string[]` 41 | 42 | Default: `['defineComponent']` 43 | 44 | The name of the function to be used for defining components. This is useful when you have a custom `defineComponent` function. 45 | 46 | ## HMR Detection 47 | 48 | This plugin supports HMR of Vue JSX components. The detection requirements are: 49 | 50 | - The component must be exported. 51 | - The component must be declared by calling `defineComponent` or the name specified in `defineComponentName` via a root-level statement, either variable declaration or export declaration. 52 | 53 | ### Supported patterns 54 | 55 | ```jsx 56 | import { defineComponent } from 'vue' 57 | 58 | // named exports w/ variable declaration: ok 59 | export const Foo = defineComponent({}) 60 | 61 | // named exports referencing variable declaration: ok 62 | const Bar = defineComponent({ render() { return
Test
}}) 63 | export { Bar } 64 | 65 | // default export call: ok 66 | export default defineComponent({ render() { return
Test
}}) 67 | 68 | // default export referencing variable declaration: ok 69 | const Baz = defineComponent({ render() { return
Test
}}) 70 | export default Baz 71 | ``` 72 | 73 | ### Non-supported patterns 74 | 75 | ```jsx 76 | // not using `defineComponent` call 77 | export const Bar = { ... } 78 | 79 | // not exported 80 | const Foo = defineComponent(...) 81 | ``` 82 | -------------------------------------------------------------------------------- /packages/plugin-vue-jsx/build.config.ts: -------------------------------------------------------------------------------- 1 | import { defineBuildConfig } from 'unbuild' 2 | 3 | export default defineBuildConfig({ 4 | entries: ['src/index'], 5 | clean: true, 6 | declaration: true, 7 | rollup: { 8 | emitCJS: true, 9 | }, 10 | }) 11 | -------------------------------------------------------------------------------- /packages/plugin-vue-jsx/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vitejs/plugin-vue-jsx", 3 | "version": "4.2.0", 4 | "type": "commonjs", 5 | "license": "MIT", 6 | "author": "Evan You", 7 | "files": [ 8 | "dist" 9 | ], 10 | "main": "./dist/index.cjs", 11 | "module": "./dist/index.mjs", 12 | "types": "./dist/index.d.ts", 13 | "exports": { 14 | ".": { 15 | "import": "./dist/index.mjs", 16 | "require": "./dist/index.cjs" 17 | } 18 | }, 19 | "scripts": { 20 | "dev": "unbuild --stub", 21 | "build": "unbuild && pnpm run patch-cjs", 22 | "patch-cjs": "tsx ../../scripts/patchCJS.ts", 23 | "prepublishOnly": "npm run build" 24 | }, 25 | "engines": { 26 | "node": "^18.0.0 || >=20.0.0" 27 | }, 28 | "repository": { 29 | "type": "git", 30 | "url": "git+https://github.com/vitejs/vite-plugin-vue.git", 31 | "directory": "packages/plugin-vue-jsx" 32 | }, 33 | "bugs": { 34 | "url": "https://github.com/vitejs/vite-plugin-vue/issues" 35 | }, 36 | "homepage": "https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx#readme", 37 | "dependencies": { 38 | "@babel/core": "^7.27.1", 39 | "@babel/plugin-transform-typescript": "^7.27.1", 40 | "@rolldown/pluginutils": "^1.0.0-beta.9", 41 | "@vue/babel-plugin-jsx": "^1.4.0" 42 | }, 43 | "devDependencies": { 44 | "vite": "catalog:" 45 | }, 46 | "peerDependencies": { 47 | "vite": "^5.0.0 || ^6.0.0", 48 | "vue": "^3.0.0" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /packages/plugin-vue-jsx/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx' 2 | import type { FilterPattern } from 'vite' 3 | 4 | export interface FilterOptions { 5 | include?: FilterPattern 6 | exclude?: FilterPattern 7 | } 8 | 9 | export interface Options extends VueJSXPluginOptions, FilterOptions { 10 | babelPlugins?: any[] 11 | /** @default ['defineComponent'] */ 12 | defineComponentName?: string[] 13 | tsPluginOptions?: any 14 | } 15 | -------------------------------------------------------------------------------- /packages/plugin-vue-jsx/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src"], 3 | "exclude": ["**/*.spec.ts"], 4 | "compilerOptions": { 5 | "outDir": "dist", 6 | "target": "ES2020", 7 | "module": "ES2020", 8 | "moduleResolution": "Node", 9 | "strict": true, 10 | "declaration": true, 11 | "sourceMap": true, 12 | "noUnusedLocals": true, 13 | "esModuleInterop": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/plugin-vue/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/plugin-vue/README.md: -------------------------------------------------------------------------------- 1 | # @vitejs/plugin-vue [![npm](https://img.shields.io/npm/v/@vitejs/plugin-vue.svg)](https://npmjs.com/package/@vitejs/plugin-vue) 2 | 3 | > Note: as of `vue` 3.2.13+ and `@vitejs/plugin-vue` 1.9.0+, `@vue/compiler-sfc` is no longer required as a peer dependency. 4 | 5 | ```js 6 | // vite.config.js 7 | import vue from '@vitejs/plugin-vue' 8 | 9 | export default { 10 | plugins: [vue()], 11 | } 12 | ``` 13 | 14 | For JSX / TSX support, [`@vitejs/plugin-vue-jsx`](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) is also needed. 15 | 16 | ## Options 17 | 18 | ```ts 19 | export interface Options { 20 | include?: string | RegExp | (string | RegExp)[] 21 | exclude?: string | RegExp | (string | RegExp)[] 22 | 23 | isProduction?: boolean 24 | 25 | /** 26 | * Requires @vitejs/plugin-vue@^5.1.0 27 | */ 28 | features?: { 29 | /** 30 | * Enable reactive destructure for `defineProps`. 31 | * - Available in Vue 3.4 and later. 32 | * - **default:** `false` in Vue 3.4 (**experimental**), `true` in Vue 3.5+ 33 | */ 34 | propsDestructure?: boolean 35 | /** 36 | * Transform Vue SFCs into custom elements. 37 | * - `true`: all `*.vue` imports are converted into custom elements 38 | * - `string | RegExp`: matched files are converted into custom elements 39 | * - **default:** /\.ce\.vue$/ 40 | */ 41 | customElement?: boolean | string | RegExp | (string | RegExp)[] 42 | /** 43 | * Set to `false` to disable Options API support and allow related code in 44 | * Vue core to be dropped via dead-code elimination in production builds, 45 | * resulting in smaller bundles. 46 | * - **default:** `true` 47 | */ 48 | optionsAPI?: boolean 49 | /** 50 | * Set to `true` to enable devtools support in production builds. 51 | * Results in slightly larger bundles. 52 | * - **default:** `false` 53 | */ 54 | prodDevtools?: boolean 55 | /** 56 | * Set to `true` to enable detailed information for hydration mismatch 57 | * errors in production builds. Results in slightly larger bundles. 58 | * - **default:** `false` 59 | */ 60 | prodHydrationMismatchDetails?: boolean 61 | /** 62 | * Customize the component ID generation strategy. 63 | * - `'filepath'`: hash the file path (relative to the project root) 64 | * - `'filepath-source'`: hash the file path and the source code 65 | * - `function`: custom function that takes the file path, source code, 66 | * whether in production mode, and the default hash function as arguments 67 | * - **default:** `'filepath'` in development, `'filepath-source'` in production 68 | */ 69 | componentIdGenerator?: 70 | | 'filepath' 71 | | 'filepath-source' 72 | | (( 73 | filepath: string, 74 | source: string, 75 | isProduction: boolean | undefined, 76 | getHash: (text: string) => string, 77 | ) => string) 78 | } 79 | 80 | // `script`, `template` and `style` are lower-level compiler options 81 | // to pass on to respective APIs of `vue/compiler-sfc` 82 | 83 | script?: Partial< 84 | Omit< 85 | SFCScriptCompileOptions, 86 | | 'id' 87 | | 'isProd' 88 | | 'inlineTemplate' 89 | | 'templateOptions' 90 | | 'sourceMap' 91 | | 'genDefaultAs' 92 | | 'customElement' 93 | > 94 | > 95 | 96 | template?: Partial< 97 | Omit< 98 | SFCTemplateCompileOptions, 99 | | 'id' 100 | | 'source' 101 | | 'ast' 102 | | 'filename' 103 | | 'scoped' 104 | | 'slotted' 105 | | 'isProd' 106 | | 'inMap' 107 | | 'ssr' 108 | | 'ssrCssVars' 109 | | 'preprocessLang' 110 | > 111 | > 112 | 113 | style?: Partial< 114 | Omit< 115 | SFCStyleCompileOptions, 116 | | 'filename' 117 | | 'id' 118 | | 'isProd' 119 | | 'source' 120 | | 'scoped' 121 | | 'cssDevSourcemap' 122 | | 'postcssOptions' 123 | | 'map' 124 | | 'postcssPlugins' 125 | | 'preprocessCustomRequire' 126 | | 'preprocessLang' 127 | | 'preprocessOptions' 128 | > 129 | > 130 | 131 | /** 132 | * Use custom compiler-sfc instance. Can be used to force a specific version. 133 | */ 134 | compiler?: typeof _compiler 135 | 136 | /** 137 | * @deprecated moved to `features.customElement`. 138 | */ 139 | customElements?: boolean | string | RegExp | (string | RegExp)[] 140 | } 141 | ``` 142 | 143 | ## Asset URL handling 144 | 145 | When `@vitejs/plugin-vue` compiles the `