File tree Expand file tree Collapse file tree
packages/weapp-tailwindcss/src/bundlers/vite Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " weapp-tailwindcss " : patch
3+ ---
4+
5+ 修复 Tailwind CSS v3 在 Vite 增量构建中只使用 source scan 候选集时遗漏当前 bundle 新增类名的问题,避免 WXML 已转义但 WXSS 未生成对应样式。
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ interface GenerateBundleContext {
4040 forceRefresh ?: boolean ,
4141 options ?: {
4242 allowBaselineOnlyInitialSync ?: boolean | undefined
43+ baseClassSet ?: Set < string > | undefined
4344 } ,
4445 ) => Promise < Set < string > >
4546 debug : ( format : string , ...args : unknown [ ] ) => void
@@ -168,7 +169,10 @@ export function createGenerateBundleHook(context: GenerateBundleContext) {
168169 && ! disableV3OxideSourceRuntime
169170 const runtimeStart = performance . now ( )
170171 const runtime = useV3OxideSourceRuntime
171- ? new Set < string > ( )
172+ ? await ensureBundleRuntimeClassSet ( snapshot , forceRuntimeRefreshByEnv , {
173+ allowBaselineOnlyInitialSync : true ,
174+ baseClassSet : sourceCandidates ,
175+ } )
172176 : useBundleRuntimeClassSet
173177 ? await ensureBundleRuntimeClassSet ( snapshot , forceRuntimeRefreshByEnv , {
174178 allowBaselineOnlyInitialSync : buildCommand ,
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ export function createViteRuntimeClassSet(options: CreateViteRuntimeClassSetOpti
113113 forceRefresh = false ,
114114 options : {
115115 allowBaselineOnlyInitialSync ?: boolean | undefined
116+ baseClassSet ?: Set < string > | undefined
116117 } = { } ,
117118 ) {
118119 const forceRuntimeRefresh = forceRefresh || process . env [ 'WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH' ] === '1'
@@ -144,8 +145,8 @@ export function createViteRuntimeClassSet(options: CreateViteRuntimeClassSetOpti
144145
145146 if ( runtimeState . twPatcher . majorVersion === 3 && ! forceRuntimeRefresh ) {
146147 try {
147- let baseClassSet : Set < string > | undefined
148- if ( ! runtimeSet || shouldRefreshPatcher ) {
148+ let baseClassSet = options . baseClassSet
149+ if ( ! baseClassSet && ( ! runtimeSet || shouldRefreshPatcher ) ) {
149150 baseClassSet = await collectRuntimeClassSet ( runtimeState . twPatcher , {
150151 force : true ,
151152 skipRefresh : shouldRefreshPatcher ,
You can’t perform that action at this time.
0 commit comments