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

build后 element-plus 样式重复加载 #17

Closed
catch6 opened this issue Apr 24, 2021 · 5 comments
Closed

build后 element-plus 样式重复加载 #17

catch6 opened this issue Apr 24, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@catch6
Copy link

catch6 commented Apr 24, 2021

我使用的 element-plus,并且配置了自定义主题, build 之后 preview 时看到的样式很多重复
image
image

相关配置如下

css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "./src/assets/style/element-plus-var.scss";`,
      },
    },
  },
.............
styleImport({
    libs: [
      {
        libraryName: 'element-plus',
        esModule: true,
        resolveStyle: (name) => {
          name = name.substr(3)
          return `element-plus/packages/theme-chalk/src/${name}.scss`
        },
        resolveComponent: (name) => {
          return `element-plus/lib/${name}`
        },
      },
    ],
  }),
// element-plus-var.scss
// element-plus 自定义主题
// 完整的变量查看: element-plus/packages/theme-chalk/src/common/var.scss
$--color-primary: #6366f1 !default;
$--color-success: #10b981 !default;
$--color-warning: #f59e0b !default;
$--color-danger: #ef4444 !default;
@catch6 catch6 changed the title element-plus 样式重复加载 build后 element-plus 样式重复加载 Apr 24, 2021
@jeff-fe
Copy link

jeff-fe commented Apr 27, 2021

我也遇到了同样的问题

@anncwb anncwb added the bug Something isn't working label Apr 28, 2021
@anncwb
Copy link
Collaborator

anncwb commented May 25, 2021

这个应该不是这个插件的问题,在less内可以使用 @import (reference) 'xxx.less';, 加上 (reference)来规避,在sass可能需要自行搜索下

@admin00001
Copy link

所以,自定义主题 + 按需引入在vite中怎么配置?还没有解决吗?

@Thyiad
Copy link

Thyiad commented Jun 16, 2021

的确会重复导入,而且自定义了主题的时候,还会导入原始的主题样式,比如 a标签:

image

暂时不知道怎么改了,直接入口文件 import 'antd/dist/antd.min.css'

反正是后台系统,无讲究

哪位兄弟有解决方案了记得留个言啊。。

@anncwb
Copy link
Collaborator

anncwb commented Aug 1, 2021

这个是改跟 ElemeFE/element#11817 类似,不是插件问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants