create-lve 0.4.31 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.js +7 -7
- package/package.json +1 -1
- package/template-react/package.json +1 -1
- package/template-react/vite.config.ts +29 -9
package/config.js
CHANGED
|
@@ -87,7 +87,6 @@ a:focus-visible {
|
|
|
87
87
|
`
|
|
88
88
|
|
|
89
89
|
const vitePlusDeps = (isUno) => ({
|
|
90
|
-
dependencies: isUno ? { '@unocss/reset': 'latest' } : undefined,
|
|
91
90
|
devDependencies: isUno ? { unocss: 'latest' } : undefined,
|
|
92
91
|
overrides: {
|
|
93
92
|
vite: 'npm:@voidzero-dev/vite-plus-core@latest',
|
|
@@ -109,12 +108,12 @@ const CSS_STRATEGIES = {
|
|
|
109
108
|
unocss: {
|
|
110
109
|
pluginImport: "import UnoCSS from 'unocss/vite'\n",
|
|
111
110
|
pluginCode: 'UnoCSS(), ',
|
|
112
|
-
entryImport: "import '
|
|
111
|
+
entryImport: "import 'virtual:uno.css'\n",
|
|
113
112
|
async setup(ctx) {
|
|
114
113
|
const unoConfig = `
|
|
115
114
|
import {
|
|
116
115
|
defineConfig,
|
|
117
|
-
|
|
116
|
+
presetWind4,
|
|
118
117
|
transformerCompileClass,
|
|
119
118
|
type SourceCodeTransformer,
|
|
120
119
|
} from 'unocss'
|
|
@@ -124,7 +123,7 @@ declare const process: { env: { NODE_ENV: string } }
|
|
|
124
123
|
const isBuild = process.env.NODE_ENV === 'production'
|
|
125
124
|
|
|
126
125
|
export default defineConfig({
|
|
127
|
-
presets: [
|
|
126
|
+
presets: [presetWind4()],
|
|
128
127
|
transformers: (isBuild
|
|
129
128
|
? [
|
|
130
129
|
{
|
|
@@ -174,8 +173,8 @@ export default defineConfig({
|
|
|
174
173
|
} catch {}
|
|
175
174
|
}
|
|
176
175
|
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
// UnoCSS 不需要 style.css,utilities 通过 virtual:uno.css 注入
|
|
177
|
+
// BASE_STYLE 已在 applyProjectTransform 中写入,此处保留
|
|
179
178
|
},
|
|
180
179
|
},
|
|
181
180
|
tailwind: {
|
|
@@ -285,7 +284,8 @@ async function applyProjectTransform(ctx) {
|
|
|
285
284
|
|
|
286
285
|
const stylePath = path.join(targetDir, 'src/style.css')
|
|
287
286
|
await fs.ensureDir(path.dirname(stylePath))
|
|
288
|
-
|
|
287
|
+
const styleContent = isUno ? `${BASE_STYLE}\n` : `@import 'tailwindcss';\n\n${BASE_STYLE}\n`
|
|
288
|
+
await fs.writeFile(stylePath, styleContent)
|
|
289
289
|
|
|
290
290
|
await strategy.setup(ctx)
|
|
291
291
|
}
|
package/package.json
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@babel/core": "latest",
|
|
22
|
-
"@rolldown/plugin-babel": "latest",
|
|
23
22
|
"@tailwindcss/vite": "latest",
|
|
24
23
|
"@types/babel__core": "latest",
|
|
25
24
|
"@types/node": "latest",
|
|
@@ -27,6 +26,7 @@
|
|
|
27
26
|
"@types/react-dom": "latest",
|
|
28
27
|
"@vitejs/plugin-react": "latest",
|
|
29
28
|
"babel-plugin-react-compiler": "latest",
|
|
29
|
+
"oxc-transform": "latest",
|
|
30
30
|
"tailwindcss": "latest",
|
|
31
31
|
"typescript": "latest",
|
|
32
32
|
"vite": "latest",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { defineConfig, loadEnv, lazyPlugins } from 'vite-plus'
|
|
2
|
-
import react
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
3
|
|
|
4
4
|
const mode = process.env.NODE_ENV || 'development'
|
|
5
5
|
const env = loadEnv(mode, process.cwd(), '')
|
|
6
|
+
// React Compiler: true = OXC (Rust native, experimental), false = Babel (official, stable)
|
|
7
|
+
const USE_OXC = true
|
|
6
8
|
|
|
7
9
|
// https://vite.dev/config/
|
|
8
10
|
export default defineConfig({
|
|
@@ -15,12 +17,31 @@ export default defineConfig({
|
|
|
15
17
|
/* VITE_PLUS_PLUGINS */
|
|
16
18
|
react(),
|
|
17
19
|
lazyPlugins(async () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (USE_OXC) {
|
|
21
|
+
const { transform } = await import('oxc-transform')
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: 'oxc-react-compiler',
|
|
25
|
+
enforce: 'pre',
|
|
26
|
+
transform(code, id) {
|
|
27
|
+
if (!/\.[tj]sx$/.test(id)) return
|
|
28
|
+
const result = transform(id, code, {
|
|
29
|
+
jsx: { runtime: 'automatic' },
|
|
30
|
+
reactCompiler: { target: '19' },
|
|
31
|
+
})
|
|
32
|
+
return { code: result.code, map: result.map }
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
]
|
|
36
|
+
} else {
|
|
37
|
+
const { reactCompilerPreset } = await import('@vitejs/plugin-react')
|
|
38
|
+
const { default: babel } = await import('@rolldown/plugin-babel')
|
|
39
|
+
return [
|
|
40
|
+
babel({
|
|
41
|
+
presets: [reactCompilerPreset()],
|
|
42
|
+
}),
|
|
43
|
+
]
|
|
44
|
+
}
|
|
24
45
|
}),
|
|
25
46
|
],
|
|
26
47
|
resolve: {
|
|
@@ -34,8 +55,7 @@ export default defineConfig({
|
|
|
34
55
|
const pkg = id.match(/node_modules\/(?:@[^/]+\/)?([^/]+)/)?.[1]
|
|
35
56
|
if (pkg === 'react') return 'vendor-react'
|
|
36
57
|
if (pkg === 'react-dom') return 'vendor-react-dom'
|
|
37
|
-
if (pkg === 'react-router'
|
|
38
|
-
return 'vendor-router'
|
|
58
|
+
if (pkg === 'react-router') return 'vendor-router'
|
|
39
59
|
if (id.includes('@tanstack')) return 'vendor-query'
|
|
40
60
|
if (pkg === 'zustand') return 'vendor-state'
|
|
41
61
|
if (pkg === 'jotai') return 'vendor-atom'
|