@@ -34,6 +34,8 @@ export function uniAppCssPrePlugin(): Plugin {
3434 const mainPath = resolveMainPathOnce ( process . env . UNI_INPUT_DIR )
3535 const appUVuePath = resolveAppVue ( process . env . UNI_INPUT_DIR )
3636 const { parseCss } = require ( '@dcloudio/compiler-vapor-dom2' )
37+ const isDom2 = process . env . UNI_APP_X_DOM2 === 'true'
38+ const isDom2Harmony = isDom2 && process . env . UNI_UTS_PLATFORM === 'app-harmony'
3739 return {
3840 name,
3941 // 需要提前,因为unocss会在configResolved读取vite:css-post插件
@@ -69,9 +71,6 @@ export function uniAppCssPrePlugin(): Plugin {
6971 platform : process . env . UNI_UTS_PLATFORM ,
7072 helper : requireUniHelpers ( ) ,
7173 } )
72- const isDom2Harmony =
73- process . env . UNI_APP_X_DOM2 === 'true' &&
74- process . env . UNI_UTS_PLATFORM === 'app-harmony'
7574 if ( isDom2Harmony && fontFaces ) {
7675 const id = CSS_FILE_ID_MAP . get ( filename )
7776 if ( id ) {
@@ -121,10 +120,6 @@ export function uniAppCssPrePlugin(): Plugin {
121120 name : 'uni:app-uvue-css-inline-post' ,
122121 apply : 'build' ,
123122 generateBundle ( _ , bundle ) {
124- // 暂时保留此条件容错
125- const isDom2Harmony =
126- process . env . UNI_APP_X_DOM2 === 'true' &&
127- process . env . UNI_UTS_PLATFORM === 'app-harmony'
128123 if ( isDom2Harmony ) {
129124 Object . entries ( bundle ) . forEach ( ( [ file , asset ] ) => {
130125 // 不支持多style标签
@@ -158,9 +153,6 @@ export function uniAppCssPrePlugin(): Plugin {
158153 // 重要:必须放到 unplugin-auto-import、uni:sd 前
159154 const index = plugins . findIndex ( ( p ) => p . name === 'unplugin-auto-import' )
160155 plugins . splice ( index , 0 , uvueCssPostPlugin )
161- const isDom2Harmony =
162- process . env . UNI_APP_X_DOM2 === 'true' &&
163- process . env . UNI_UTS_PLATFORM === 'app-harmony'
164156 if ( isDom2Harmony ) {
165157 plugins . splice ( index + 1 , 0 , uvueCssInlinePostPlugin )
166158 }
0 commit comments