Skip to content

Commit 91526e9

Browse files
committed
feat: 鸿蒙配置添加是否支持css变量解析开关
1 parent f1a5b48 commit 91526e9

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/taro-vite-runner/src/harmony/postcss/compile.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export async function compileCSS(
3131
code: string,
3232
config: ResolvedConfig,
3333
urlReplacer?: CssUrlReplacer,
34-
isGlobalModule ?: boolean
34+
isGlobalModule ?: boolean,
35+
cssVariable?: boolean
3536
): Promise<{
3637
code: string
3738
map?: SourceMapInput
@@ -208,7 +209,9 @@ export async function compileCSS(
208209
)
209210
}
210211

211-
postcssPlugins.push((await import('postcss-css-variables')).default({}))
212+
if (cssVariable !== true) {
213+
postcssPlugins.push((await import('postcss-css-variables')).default({}))
214+
}
212215

213216
if (!postcssPlugins.length) {
214217
return {

packages/taro-vite-runner/src/harmony/style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export async function stylePlugin(viteCompilerContext: ViteHarmonyCompilerContex
254254
modules,
255255
deps,
256256
map,
257-
} = await compileCSS(id, raw, viteConfig, urlReplacer, isGlobalModule)
257+
} = await compileCSS(id, raw, viteConfig, urlReplacer, isGlobalModule, taroConfig.cssVariables)
258258

259259
// if (!cssCache.has(id)) {
260260

packages/taro/types/compile/viteCompilerContext.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export interface ViteHarmonyBuildConfig extends CommonBuildConfig, IHarmonyConfi
5959
runtimePath?: string | string[]
6060
isPure?: boolean
6161
taroComponentsPath: string
62+
cssVariables?: boolean // 是否动态解析css变量
6263
}
6364

6465
export interface CommonBuildConfig extends IProjectConfig<'vite'> {

0 commit comments

Comments
 (0)