Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add global scss #2798

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/nutui-taro-demo/src/app.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../../../src/styles/jd-font.scss';
oasis-cloud marked this conversation as resolved.
Show resolved Hide resolved

body {
font-size: 14px;
}
Expand Down
19 changes: 8 additions & 11 deletions scripts/build-taro.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,19 @@ async function copyStyles() {
resolve(__dirname, '../dist/styles'),
)

const content = [
let content = [
`@import '../theme-default.scss';`,
`@import '../variables.scss';`,
`@import '../mixins/index.scss';`,
`@import '../animation/index.scss';`,
`@import '../theme-dark.scss';`,
`@import '../font-face.scss';`,
]
const projectID = process.env.VITE_APP_PROJECT_ID
if (projectID) {
content[1] = `@import '../variables-${projectID}.scss';`
content = [
`@import '../theme-${projectID}.scss';`,
oasis-cloud marked this conversation as resolved.
Show resolved Hide resolved
`@import '../font-face.scss';`,
]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

需要添加缺失的 font-face.scss 文件

检查结果显示:

  • 项目中存在多个主题文件(theme-dark.scss、theme-default.scss、theme-jmapp.scss、theme-jrkf.scss),且内容结构正确
  • 但是缺少构建脚本中引用的 font-face.scss 文件

建议:

  • 在 src/styles 目录下创建 font-face.scss 文件
  • 或者从构建脚本中移除对 font-face.scss 的引用
🔗 Analysis chain

验证项目特定主题文件的存在性

当设置了 VITE_APP_PROJECT_ID 环境变量时,构建脚本会尝试导入项目特定的主题文件。需要确保这些主题文件在指定位置存在。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证项目特定主题文件是否存在

# 检查主题文件
fd -t f "theme-.*\.scss$" "src/styles"

Length of output: 150


Script:

#!/bin/bash
# 检查主题文件的内容结构,确保它们是有效的 SCSS 文件
for theme in $(fd -t f "theme-.*\.scss$" "src/styles"); do
  echo "=== $theme 内容 ==="
  head -n 5 "$theme"
  echo
done

# 检查 font-face.scss 文件是否存在及其内容
echo "=== font-face.scss 文件检查 ==="
fd -t f "font-face.scss$" "src/styles" -x head -n 5 {}

Length of output: 1380

}
const scssFiles = await glob(['dist/es/packages/**/*.scss'])
scssFiles.forEach((file) => {
content.push(
`@import '${relativeFilePath('/dist/styles/themes/default.scss', '/' + file)}';`,
)
})

dest('dist/styles/themes/default.scss', content.join('\n'))
}

Expand Down
19 changes: 8 additions & 11 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,19 @@ async function copyStyles() {
resolve(__dirname, '../dist/styles')
)

const content = [
let content = [
`@import '../theme-default.scss';`,
`@import '../variables.scss';`,
`@import '../mixins/index.scss';`,
`@import '../animation/index.scss';`,
`@import '../theme-dark.scss';`,
`@import '../font-face.scss';`,
]
const projectID = process.env.VITE_APP_PROJECT_ID
if (projectID) {
content[1] = `@import '../variables-${projectID}.scss';`
content = [
`@import '../theme-${projectID}.scss';`,
`@import '../font-face.scss';`,
]
}
const scssFiles = await glob(['dist/es/packages/**/*.scss'])
scssFiles.forEach((file) => {
content.push(
`@import '${relativeFilePath('/dist/styles/themes/default.scss', '/' + file)}';`
)
})

dest('dist/styles/themes/default.scss', content.join('\n'))
}

Expand Down
2 changes: 2 additions & 0 deletions src/sites/mobile/App.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '../../styles/jd-font.scss';

html,
body {
&::-webkit-scrollbar {
Expand Down
8 changes: 8 additions & 0 deletions src/styles/jd-font.scss
Original file line number Diff line number Diff line change
@@ -0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AEcAWQAgAEMATwAuACwAIABMAFQARABKAEQAWgBoAGUAbgBnAEgAZQBpACAAVgAyAC4AMAAgAEoARABaAGgAZQBuAGcASABlAGkAIABWADIALgAwAFIAZQBnAHUAbABhAHIAMgAuADAAMAAwADsAVQBLAFcATgA7AEoARABaAGgAZQBuAGcASABlAGkAVgAyAC4AMAAtAFIAZQBnAHUAbABhAHIASgBEAFoAaABlAG4AZwBIAGUAaQAgAFYAMgAuADAAIABSAGUAZwB1AGwAYQByAFYAZQByAHMAaQBvAG4AIAAyAC4AMAAwADAAOwBHAGwAeQBwAGgAcwAgADMALgAxAC4AMQAgACgAMwAxADMANQApAEoARABaAGgAZQBuAGcASABlAGkAVgAyAC4AMAAtAFIAZQBnAHUAbABhAHIATgBlAHcAIABWAGEAbAB1AGWWdnQ8AEoARABaAGgAZQBuAGcASABlAGkAIABWADIALgAwAEIAeQAgAEIARQBJAEoASQBOAEcAIABKAEkATgBHAEQATwBOAEcAIABUAEUAQwBIAE4ATwBMAE8ARwBZACAAQwBPAC4ALAAgAEwAVABEAAAAAAIAAAAAAAD/NABmAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAEAAgADABMAFAAVABYAFwAYABkAGgAbABwAAAAAAAH//wACAAEAAAAMAAAAAAAAAAIAAQADAA0AAQAA')
format('truetype');
font-weight: 400;
font-style: normal;
font-display: swap;
}
Loading