Skip to content

Commit 74fa619

Browse files
committed
feat: make jsx support optional
1 parent b715549 commit 74fa619

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

index.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,15 @@ async function init() {
102102
isValidPackageName(dir) || 'Invalid package.json name'
103103
},
104104
{
105-
name: 'shouldUseTypeScript',
105+
name: 'shouldAddJSX',
106+
type: () => (isValidTemplate ? null : 'toggle'),
107+
message: 'Add JSX Support?',
108+
initial: false,
109+
active: 'Yes',
110+
inactive: 'No'
111+
},
112+
{
113+
name: 'shouldAddTypeScript',
106114
type: () => (isValidTemplate ? null : 'toggle'),
107115
message: 'Add TypeScript?',
108116
initial: false,
@@ -143,7 +151,8 @@ async function init() {
143151
const {
144152
packageName = toValidPackageName(defaultProjectName),
145153
shouldOverwrite,
146-
shouldUseTypeScript = isValidTemplate && template.includes('-ts'),
154+
shouldAddJSX,
155+
shouldAddTypeScript = isValidTemplate && template.includes('-ts'),
147156
isSPA = isValidTemplate && template.includes('spa'),
148157
shouldAddCypress = isValidTemplate && template.includes('-with-tests')
149158
} = result
@@ -171,10 +180,13 @@ async function init() {
171180

172181
// Add configs.
173182
render('config/base')
183+
if (shouldAddJSX) {
184+
render('config/jsx')
185+
}
174186
if (shouldAddCypress) {
175187
render('config/cypress')
176188
}
177-
if (shouldUseTypeScript) {
189+
if (shouldAddTypeScript) {
178190
render('config/typescript')
179191

180192
// rename all `.js` files to `.ts`
@@ -198,7 +210,7 @@ async function init() {
198210
// Render code template.
199211
// prettier-ignore
200212
const codeTemplate =
201-
(shouldUseTypeScript ? 'typescript-' : '') +
213+
(shouldAddTypeScript ? 'typescript-' : '') +
202214
(isSPA ? 'spa' : 'default')
203215
render(`code/${codeTemplate}`)
204216

template/config/base/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
},
1111
"devDependencies": {
1212
"@vitejs/plugin-vue": "^1.2.5",
13-
"@vitejs/plugin-vue-jsx": "^1.1.6",
1413
"@vue/compiler-sfc": "^3.1.5",
1514
"vite": "^2.4.3"
1615
}

template/config/base/vite.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
3-
import vueJsx from '@vitejs/plugin-vue-jsx'
43

54
// https://vitejs.dev/config/
65
export default defineConfig({
7-
plugins: [vue(), vueJsx()],
6+
plugins: [vue()],
87
resolve: {
98
alias: {
109
'@/': new URL('./src/', import.meta.url).pathname

template/config/jsx/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"devDependencies": {
3+
"@vitejs/plugin-vue-jsx": "^1.1.6"
4+
}
5+
}

template/config/jsx/vite.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'vite'
2+
import vue from '@vitejs/plugin-vue'
3+
import vueJsx from '@vitejs/plugin-vue-jsx'
4+
5+
// https://vitejs.dev/config/
6+
export default defineConfig({
7+
plugins: [vue(), vueJsx()],
8+
resolve: {
9+
alias: {
10+
'@/': new URL('./src/', import.meta.url).pathname
11+
}
12+
}
13+
})

0 commit comments

Comments
 (0)