NervJS / taro-ui

一款基于 Taro 框架开发的多端 UI 组件库
https://taro-ui.taro.zone
MIT License
4.53k stars 758 forks source link

组件按需加载样式重复导入,导致variables 变量覆盖无效 #1717

Closed superchow closed 8 months ago

superchow commented 10 months ago

开启按需加载、自定义主题后,发现主题不生效,经排查发现组件的样式导入了两次😥

image

在 app.scss中的样式是正确的,但是在page页面多了一个组件的默认样式导入

"@tarojs/cli": "3.6.19",
"webpack": "^5.78.0"
"taro-ui": "3.2.0"
....

babel.config.js 配置如下:

module.exports = {
  presets: [
    [
      'taro',
      {
        framework: 'react',
        ts: true,
        'dynamic-import-node': true,
      },
    ],
  ],
  plugins: [
    [
      'import',
      {
        libraryName: 'taro-ui',
        customName: (name) => `taro-ui/lib/components/${name.slice(3)}`,
        customStyleName: (name) =>
          `taro-ui/dist/style/components/${name.slice(3)}.scss`,
      },
    ],
  ],
}
taro-ui-bot[bot] commented 10 months ago

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

robinv8 commented 9 months ago

经测试开启 babel 按需加载组件后还不支持自定义主题,目前只支持在页面或全局样式中引入组件样式

$color-brand: #f00;
@import '~taro-ui/dist/style/components/button.scss';
image