create-lve 0.5.3 → 0.6.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 CHANGED
@@ -87,6 +87,7 @@ a:focus-visible {
87
87
  `
88
88
 
89
89
  const vitePlusDeps = (isUno) => ({
90
+ dependencies: isUno ? { '@unocss/reset': 'latest' } : undefined,
90
91
  devDependencies: isUno ? { unocss: 'latest' } : undefined,
91
92
  overrides: {
92
93
  vite: 'npm:@voidzero-dev/vite-plus-core@latest',
@@ -94,17 +95,13 @@ const vitePlusDeps = (isUno) => ({
94
95
  },
95
96
  })
96
97
 
97
- const reactDeps = (isUno) => ({
98
- devDependencies: isUno ? { unocss: 'latest' } : undefined,
99
- })
100
-
101
98
  const FRAMEWORK_CONFIG = {
102
99
  next: {
103
100
  deps: (isUno) => ({
104
101
  devDependencies: isUno ? { unocss: 'latest' } : { tailwindcss: 'latest' },
105
102
  }),
106
103
  },
107
- react: { deps: reactDeps },
104
+ react: { deps: vitePlusDeps },
108
105
  vue: { deps: vitePlusDeps },
109
106
  }
110
107
 
@@ -112,12 +109,12 @@ const CSS_STRATEGIES = {
112
109
  unocss: {
113
110
  pluginImport: "import UnoCSS from 'unocss/vite'\n",
114
111
  pluginCode: 'UnoCSS(), ',
115
- entryImport: "import 'virtual:uno.css'\n",
112
+ entryImport: "import '@unocss/reset/tailwind.css'\nimport 'virtual:uno.css'\n",
116
113
  async setup(ctx) {
117
114
  const unoConfig = `
118
115
  import {
119
116
  defineConfig,
120
- presetWind4,
117
+ presetWind3,
121
118
  transformerCompileClass,
122
119
  type SourceCodeTransformer,
123
120
  } from 'unocss'
@@ -127,7 +124,7 @@ declare const process: { env: { NODE_ENV: string } }
127
124
  const isBuild = process.env.NODE_ENV === 'production'
128
125
 
129
126
  export default defineConfig({
130
- presets: [presetWind4()],
127
+ presets: [presetWind3()],
131
128
  transformers: (isBuild
132
129
  ? [
133
130
  {
@@ -177,8 +174,8 @@ export default defineConfig({
177
174
  } catch {}
178
175
  }
179
176
 
180
- // UnoCSS 不需要 style.css,utilities 通过 virtual:uno.css 注入
181
- // BASE_STYLE 已在 applyProjectTransform 中写入,此处保留
177
+ const stylePath = path.join(ctx.targetDir, 'src/style.css')
178
+ if (fs.existsSync(stylePath)) await fs.remove(stylePath)
182
179
  },
183
180
  },
184
181
  tailwind: {
@@ -288,8 +285,7 @@ async function applyProjectTransform(ctx) {
288
285
 
289
286
  const stylePath = path.join(targetDir, 'src/style.css')
290
287
  await fs.ensureDir(path.dirname(stylePath))
291
- const styleContent = isUno ? `${BASE_STYLE}\n` : `@import 'tailwindcss';\n\n${BASE_STYLE}\n`
292
- await fs.writeFile(stylePath, styleContent)
288
+ await fs.writeFile(stylePath, `@import 'tailwindcss';\n\n${BASE_STYLE}\n`)
293
289
 
294
290
  await strategy.setup(ctx)
295
291
  }
package/index.js CHANGED
@@ -111,20 +111,20 @@ async function main() {
111
111
  templateDir: path.resolve(__dirname, `template-${project.framework}`),
112
112
  isNext: project.framework === 'next',
113
113
  isUno: project.cssEngine === 'unocss',
114
- pkgManager: project.framework === 'next' ? 'pnpm' : project.framework === 'vue' ? 'vp' : 'pnpm',
115
- devCmd: project.framework === 'next' ? 'pnpm dev' : project.framework === 'vue' ? 'vp dev' : 'pnpm dev',
116
- fmtCmd: project.framework === 'next' ? 'pnpm fmt' : project.framework === 'vue' ? 'vp fmt' : 'pnpm fmt',
114
+ pkgManager: project.framework === 'next' ? 'pnpm' : 'vp',
115
+ devCmd: project.framework === 'next' ? 'pnpm dev' : 'vp dev',
116
+ fmtCmd: project.framework === 'next' ? 'pnpm fmt' : 'vp fmt',
117
117
  }
118
118
 
119
119
  const s = p.spinner()
120
120
 
121
- if (project.framework === 'vue') {
121
+ if (!ctx.isNext) {
122
122
  try {
123
123
  execSync('vp --version', { stdio: 'ignore' })
124
124
  } catch {
125
125
  p.log.error(pc.red('未检测到 VitePlus (vp) 环境'))
126
126
  p.note(
127
- pc.white(`Vue 模板依赖 vp 工具链:\n${pc.cyan('https://viteplus.dev/guide')}`),
127
+ pc.white(`React/Vue 模板依赖 vp 工具链:\n${pc.cyan('https://viteplus.dev/guide')}`),
128
128
  '环境缺失',
129
129
  )
130
130
  process.exit(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lve",
3
- "version": "0.5.3",
3
+ "version": "0.6.1",
4
4
  "bin": {
5
5
  "create-lve": "index.js"
6
6
  },
@@ -1,2 +1 @@
1
- npx oxlint --fix
2
- npx oxfmt
1
+ vp staged
@@ -1,3 +1,3 @@
1
1
  {
2
- "recommendations": ["oxc.oxc-vscode"]
2
+ "recommendations": ["VoidZero.vite-plus-extension-pack"]
3
3
  }
@@ -4,13 +4,10 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "vite",
8
- "build": "tsc -b && vite build",
9
- "preview": "vite preview",
10
- "lint": "oxlint",
11
- "lint:fix": "oxlint --fix",
12
- "fmt": "oxfmt",
13
- "fmt:check": "oxfmt --check"
7
+ "dev": "vp dev",
8
+ "build": "tsc -b && vp build",
9
+ "preview": "vp preview",
10
+ "prepare": "vp config"
14
11
  },
15
12
  "dependencies": {
16
13
  "@tanstack/react-query": "latest",
@@ -21,19 +18,18 @@
21
18
  "zustand": "latest"
22
19
  },
23
20
  "devDependencies": {
21
+ "@babel/core": "latest",
22
+ "@rolldown/plugin-babel": "latest",
24
23
  "@tailwindcss/vite": "latest",
24
+ "@types/babel__core": "latest",
25
25
  "@types/node": "latest",
26
26
  "@types/react": "latest",
27
27
  "@types/react-dom": "latest",
28
28
  "@vitejs/plugin-react": "latest",
29
- "oxc-transform": "latest",
30
- "oxfmt": "latest",
31
- "oxlint": "latest",
29
+ "babel-plugin-react-compiler": "latest",
32
30
  "tailwindcss": "latest",
33
31
  "typescript": "latest",
34
- "vite": "latest"
35
- },
36
- "lint-staged": {
37
- "*": "oxfmt --no-error-on-unmatched-pattern"
32
+ "vite": "latest",
33
+ "vite-plus": "latest"
38
34
  }
39
35
  }
@@ -1,32 +1,30 @@
1
- import { defineConfig, loadEnv, type Plugin } from 'vite'
2
- import react from '@vitejs/plugin-react'
1
+ import { defineConfig, loadEnv, lazyPlugins } from 'vite-plus'
2
+ import react, { reactCompilerPreset } from '@vitejs/plugin-react'
3
3
 
4
4
  const mode = process.env.NODE_ENV || 'development'
5
5
  const env = loadEnv(mode, process.cwd(), '')
6
6
 
7
- // OXC — Rust native, experimental
8
- function oxcReactCompiler(): Plugin {
9
- return {
10
- name: 'oxc-react-compiler',
11
- enforce: 'pre',
12
- async transform(code, id) {
13
- if (!/\.[tj]sx$/.test(id)) return
14
- const { transform } = await import('oxc-transform')
15
- const result = await transform(id, code, {
16
- jsx: { runtime: 'automatic' },
17
- reactCompiler: { target: '19' },
18
- })
19
- return { code: result.code, map: result.map }
20
- },
21
- }
22
- }
23
-
24
7
  // https://vite.dev/config/
25
8
  export default defineConfig({
9
+ fmt: { semi: false, singleQuote: true },
10
+ staged: {
11
+ '*': 'vp check --fix',
12
+ },
13
+ lint: { options: { typeAware: true, typeCheck: true } },
26
14
  plugins: [
27
15
  /* VITE_PLUS_PLUGINS */
28
- oxcReactCompiler(),
29
16
  react(),
17
+ // lazyPlugins 返回类型与 Vite plugins 字段类型不兼容
18
+ // 上游 issue: vitejs/vite#22085,官方确认为已知问题
19
+ // see: https://github.com/voidzero-dev/vite-plus/pull/1215
20
+ lazyPlugins(async () => {
21
+ const { default: babel } = await import('@rolldown/plugin-babel')
22
+ return [
23
+ babel({
24
+ presets: [reactCompilerPreset()],
25
+ }),
26
+ ]
27
+ }) as any,
30
28
  ],
31
29
  resolve: {
32
30
  tsconfigPaths: true,
@@ -36,18 +34,12 @@ export default defineConfig({
36
34
  output: {
37
35
  manualChunks(id) {
38
36
  if (!id.includes('node_modules')) return
39
- // pnpm: node_modules/.pnpm/pkg@ver/node_modules/real-pkg/...
40
- // npm: node_modules/real-pkg/...
41
- const match = id.match(
42
- /node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(@[^/]+\/[^/]+|[^/]+)/,
43
- )
44
- const pkg = match?.[1]
45
- if (pkg === 'react') return 'vendor-react'
46
- if (pkg === 'react-dom') return 'vendor-react-dom'
47
- if (pkg === 'react-router') return 'vendor-router'
37
+ if (id.includes('react') && !id.includes('react-router')) return 'vendor-react'
38
+ if (id.includes('react-dom')) return 'vendor-react-dom'
39
+ if (id.includes('react-router')) return 'vendor-router'
48
40
  if (id.includes('@tanstack')) return 'vendor-query'
49
- if (pkg === 'zustand') return 'vendor-state'
50
- if (pkg === 'jotai') return 'vendor-atom'
41
+ if (id.includes('zustand')) return 'vendor-state'
42
+ if (id.includes('jotai')) return 'vendor-atom'
51
43
  return 'vendor'
52
44
  },
53
45
  },
@@ -1,7 +0,0 @@
1
- {
2
- "semi": false,
3
- "singleQuote": true,
4
- "trailingComma": "all",
5
- "sortImports": true,
6
- "sortTailwindcss": true
7
- }
@@ -1,8 +0,0 @@
1
- {
2
- "rules": {
3
- "typescript/no-unused-vars": "error",
4
- "typescript/no-explicit-any": "warn",
5
- "react/rules-of-hooks": "error",
6
- "react/exhaustive-deps": "warn"
7
- }
8
- }