Skip to content

Commit 3e490c3

Browse files
committed
feat: automatically detect vue version
1 parent 821c35f commit 3e490c3

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default {
8686

8787
## Vue 2 Support
8888

89-
From `v0.7`, we support Vue 2 with [`vite-plugin-vue2`](https://github.com/underfin/vite-plugin-vue2)
89+
It just works.
9090

9191
```ts
9292
// vite.config.js
@@ -96,9 +96,7 @@ import ViteComponents from 'vite-plugin-components'
9696
export default {
9797
plugins: [
9898
createVuePlugin(),
99-
ViteComponents({
100-
transformer: 'vue2', // <--
101-
}),
99+
ViteComponents(),
102100
],
103101
}
104102
```

examples/vue2/vite.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import ViteComponents from 'vite-plugin-components'
55
const config: UserConfig = {
66
plugins: [
77
createVuePlugin(),
8-
ViteComponents({
9-
transformer: 'vue2',
10-
}),
8+
ViteComponents(),
119
],
1210
}
1311

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ function VitePluginComponents(options: Options = {}): Plugin {
1313
name: 'vite-plugin-components',
1414
enforce: 'post',
1515
configResolved(config) {
16+
if (config.plugins.find(i => i.name === 'vite-plugin-vue2'))
17+
options.transformer = options.transformer || 'vue2'
18+
1619
ctx = new Context(options, config)
1720
transformers = [
1821
ctx.options.transformer === 'vue2'

0 commit comments

Comments
 (0)