Skip to content

Commit

Permalink
fix: 修复 1.0 的 APP 端 NVUE 条件编译(不完美)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Mar 8, 2024
1 parent d84fbf1 commit be83a68
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1613,17 +1613,24 @@ const preCssExtNames = ['.scss', '.sass', '.styl', '.stylus']
* 目前主要解决 scss 文件被 @import 的条件编译
*/
export function rewriteScssReadFileSync() {
// 目前 1.0 App 端,只要包含了APP-NVUE条件编译,就不pre,因为区分不出来APP-NVUE
const ignoreAppNVue =
process.env.UNI_APP_X !== 'true' &&
(process.env.UNI_PLATFORM === 'app' ||
process.env.UNI_PLATFORM === 'app-plus')
const { readFileSync } = nodeFs
nodeFs.readFileSync = ((filepath, options) => {
const content = readFileSync(filepath, options)
if (
isString(filepath) &&
isString(content) &&
preCssExtNames.includes(path.extname(filepath)) &&
content.includes('#endif') &&
content.includes('#endif')
// 目前无法区分app-nvue
!content.includes('APP-NVUE')
) {
if (ignoreAppNVue && content.includes('APP-NVUE')) {
return content
}
return preCss(content)
}
return content
Expand Down

0 comments on commit be83a68

Please sign in to comment.