create-lve 0.4.4 → 0.4.6
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 +35 -27
- package/package.json +1 -1
package/config.js
CHANGED
|
@@ -70,40 +70,48 @@ const FRAMEWORK_CONFIG = {
|
|
|
70
70
|
const CSS_STRATEGIES = {
|
|
71
71
|
unocss: {
|
|
72
72
|
pluginImport: "import UnoCSS from 'unocss/vite'\n",
|
|
73
|
-
pluginCode: 'UnoCSS(), ',
|
|
73
|
+
pluginCode: 'UnoCSS({ hmrTopLevelAwait: true }), ',
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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')
|