create-lve 0.4.5 → 0.4.7

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.
Files changed (3) hide show
  1. package/config.js +34 -26
  2. package/index.js +4 -4
  3. package/package.json +1 -1
package/config.js CHANGED
@@ -74,36 +74,44 @@ const CSS_STRATEGIES = {
74
74
  entryImport: "import '@unocss/reset/tailwind.css'\nimport 'virtual:uno.css'\n",
75
75
  async setup(ctx) {
76
76
  const unoConfig = `
77
- import { defineConfig, presetWind3, transformerCompileClass } from 'unocss'
77
+ import { defineConfig, presetWind3, transformerCompileClass, SourceCodeTransformer } from 'unocss'
78
+
79
+ declare const process: { env: { NODE_ENV: string } }
80
+
81
+ const isBuild = process.env.NODE_ENV === 'production'
78
82
 
79
83
  export default defineConfig({
80
84
  presets: [presetWind3()],
81
- transformers: [
82
- {
83
- name: 'auto-uno-injector',
84
- enforce: 'pre',
85
- idFilter(id) {
86
- return /\\.[tj]sx$|\\.vue$/.test(id)
87
- },
88
- async transform(code) {
89
- const classRegex = /(?:class|className)=["']([^"']+)["']/g
90
- let match
91
- while ((match = classRegex.exec(code.original))) {
92
- const content = match[1]
93
- if (content.trim() && !content.includes(':uno:')) {
94
- const insertPos = match.index + match[0].indexOf(content)
95
- code.appendLeft(insertPos, ':uno: ')
96
- }
97
- }
98
- },
99
- },
100
- transformerCompileClass({
101
- classPrefix: '',
102
- hashFn: (str) => btoa(str).slice(0, 6),
103
- keepUnknown: false,
104
- }),
105
- ],
85
+ transformers: (isBuild
86
+ ? [
87
+ {
88
+ name: 'auto-uno-injector',
89
+ enforce: 'pre',
90
+ idFilter(id) {
91
+ return /\\.[tj]sx$|\\.vue$/.test(id)
92
+ },
93
+ async transform(code) {
94
+ const s = code as any
95
+ const classRegex = /(?:class|className)=["']([^"']+)["']/g
96
+ let match
97
+ while ((match = classRegex.exec(s.original))) {
98
+ const content = match[1]
99
+ if (content.trim() && !content.includes(':uno:')) {
100
+ const insertPos = match.index + match[0].indexOf(content)
101
+ s.appendLeft(insertPos, ':uno: ')
102
+ }
103
+ }
104
+ },
105
+ },
106
+ transformerCompileClass({
107
+ classPrefix: '',
108
+ hashFn: (str) => btoa(str).slice(0, 6),
109
+ keepUnknown: false,
110
+ }),
111
+ ]
112
+ : []) as SourceCodeTransformer[],
106
113
  })
114
+
107
115
  `.trim()
108
116
  await fs.writeFile(path.join(ctx.targetDir, 'uno.config.ts'), unoConfig + '\n')
109
117
  const stylePath = path.join(ctx.targetDir, 'src/style.css')
package/index.js CHANGED
@@ -23,8 +23,8 @@ async function main() {
23
23
  path: () =>
24
24
  p.text({
25
25
  message: '项目名称',
26
- placeholder: 'react-app',
27
- defaultValue: 'react-app',
26
+ placeholder: 'vue-app',
27
+ defaultValue: 'vue-app',
28
28
  validate: (value) => {
29
29
  if (!value || value.length === 0) return
30
30
  if (value.match(/[<>:"|?*]/)) return '路径包含非法字符'
@@ -42,8 +42,8 @@ async function main() {
42
42
  p.select({
43
43
  message: '选择框架',
44
44
  options: [
45
- { value: 'react', label: 'React 19', hint: '' },
46
45
  { value: 'vue', label: 'Vue 3', hint: '' },
46
+ { value: 'react', label: 'React 19', hint: '' },
47
47
  { value: 'next', label: 'Next.js 16', hint: '' },
48
48
  ],
49
49
  }),
@@ -54,8 +54,8 @@ async function main() {
54
54
  : p.select({
55
55
  message: '选择 CSS',
56
56
  options: [
57
- { value: 'tailwind', label: 'Tailwind v4' },
58
57
  { value: 'unocss', label: 'UnoCSS' },
58
+ { value: 'tailwind', label: 'Tailwind v4' },
59
59
  ],
60
60
  }),
61
61
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lve",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "bin": {
5
5
  "create-lve": "index.js"
6
6
  },