element icon indicating copy to clipboard operation
element copied to clipboard

[Bug Report] custom theme, CSS repeated multiple times

Open gangyeona opened this issue 7 years ago • 69 comments
trafficstars

Element UI version

2.4.2

OS/Browsers version

ubuntu16.4

Vue version

2.5.17-beta.0

Reproduction Link

https://jsfiddle.net/mmx38qxw/localproject

Steps to reproduce

按照官网2种自定义主题步骤操作,设置好新的主题后,打开项目页面,从控制台可以看到button,input等空间的样式重复多次,有4次,7次甚至更多次. 使用webpack css去重插件也不生效

What is Expected?

css样式不重复

What is actually happening?

css样式重复

gangyeona avatar Jul 02 '18 03:07 gangyeona

Translation of this issue:

Element UI version 2.4.2

OS/Browsers version Ubuntu16.4

Vue version 2.5.17-beta.0

Reproduction Link https://jsfiddle.net/mmx38qxw/localproject

Steps to reproduce According to the operation of 2 custom theme steps of the official network, after setting up a new theme, opening the project page, from the console, you can see that the style of button, input and other spaces can be repeated many times, 4 times, 7 times or even more times.

The use of webpack CSS to remove the plug-in is not effective What is Expected?

CSS style does not repeat What is actually happening?

CSS style duplication

element-bot avatar Jul 02 '18 03:07 element-bot

I meet the same problem

ashen9 avatar Jul 02 '18 03:07 ashen9

@ashen9 请问你解决了吗

gangyeona avatar Jul 27 '18 03:07 gangyeona

Same problem on 2.4.6, make my custom template overridden by the default one.

Edhilion avatar Aug 13 '18 07:08 Edhilion

In my project same styling gets repeated > 10 times. I believe it might have something to do with the webpack setup?

ststaynov avatar Aug 13 '18 08:08 ststaynov

@ststaynov i had tried to add some plugins to deal css in webpackconfigs,but nothing happend

gangyeona avatar Aug 22 '18 05:08 gangyeona

Same to me ( I got 7 times), and I used this way http://element-cn.eleme.io/#/zh-CN/component/custom-theme#zai-xiang-mu-zhong-gai-bian-scss-bian-liang

hanzhangyu avatar Sep 07 '18 03:09 hanzhangyu

Did somebody managed to resolve this? :/

ststaynov avatar Sep 24 '18 12:09 ststaynov

I have the same problem.

driesdesmet avatar Oct 01 '18 14:10 driesdesmet

@ashen9 请问你解决了吗

没有,应该是按需加载时各个组件有重复定义的class,改成全量加载后,element打包去重了

ashen9 avatar Oct 08 '18 01:10 ashen9

Same issue; If want to use input & input-number, and import styles and components on demand, I have styles included twice, because, for my example, in file: input-number.scss i have: @import "input"; Why was it imported in all components? Not enough mixins & vars? 👎

7iomka avatar Oct 18 '18 19:10 7iomka

Same problem.

zimuZhao avatar Nov 07 '18 06:11 zimuZhao

same here

truefalse10 avatar Nov 07 '18 09:11 truefalse10

"element-ui": "^2.4.5" same problem

Zver64 avatar Nov 14 '18 06:11 Zver64

same problem 怀疑是否现部分scss文件的引用有问题 以下是dropdown.scss的头部

@import "mixins/mixins";
@import "common/var";
@import "button";
@import "./popper";

是不是这里@import了button导致button样式重复编译


fast-sass-loader can fix this bug. It can remove the duplication code.

chenzhq avatar Dec 28 '18 09:12 chenzhq

same problem v2.6.1 on nuxt

edum18 avatar Mar 11 '19 17:03 edum18

repeat

lingsang2 avatar Mar 21 '19 02:03 lingsang2

same! and its killing me. I doubt whether this is because element does not make use of sass partials.

praveenpuglia avatar Apr 09 '19 13:04 praveenpuglia

The problem still exist in version 2.7, how to fix this?

AndrewLamYW avatar Apr 12 '19 10:04 AndrewLamYW

the same on 2.8.0

okosowski avatar Apr 25 '19 09:04 okosowski

@Leopoldthecoder @QingWei-Li are you aware of this?

same problem 怀疑是否现部分scss文件的引用有问题 以下是dropdown.scss的头部

@import "mixins/mixins";
@import "common/var";
@import "button";
@import "./popper";

是不是这里@import了button导致button样式重复编译

fast-sass-loader can fix this bug. It can remove the duplication code.

@chenzhq 指出了问题的根源。多处scss 组件模块重复引用了其他模块,导致本地开发会看到多份重复样式,只是因为 production build 的时候被自动dedup了

e-cloud avatar May 19 '19 02:05 e-cloud

@Leopoldthecoder @QingWei-Li 移除组件内部的重复引用是否可行?还是说因为要兼顾按需引用的特性才搞成这样?

e-cloud avatar May 19 '19 02:05 e-cloud

@Leopoldthecoder @QingWei-Li are you aware of this?

same problem 怀疑是否现部分scss文件的引用有问题 以下是dropdown.scss的头部

@import "mixins/mixins";
@import "common/var";
@import "button";
@import "./popper";

是不是这里@import了button导致button样式重复编译 fast-sass-loader can fix this bug. It can remove the duplication code.

@chenzhq 指出了问题的根源。多处scss 组件模块重复引用了其他模块,导致本地开发会看到多份重复样式,只是因为 production build 的时候被自动dedup了

using fast-sass-loader only fixes it on production? or also on dev?

edum18 avatar May 19 '19 19:05 edum18

@edum18 both. Depend on your webpack or vue.config.js. you can use it to replace the sass-loader.

This is not an elegant solution.

chenzhq avatar May 21 '19 06:05 chenzhq

Anybody tested on the latest version 2.9.1?

AndrewLamYW avatar Jun 03 '19 00:06 AndrewLamYW

Anybody tested on the latest version 2.9.1?

Yeah, problem is still there...

JBtje avatar Jun 03 '19 07:06 JBtje

same problem here with [email protected]

valterbarros avatar Jun 07 '19 14:06 valterbarros

I have the same problem with [email protected]

KeziahMoselle avatar Jun 08 '19 10:06 KeziahMoselle

I tried to do that but it didn't work。Where is the configuration error?CSS repeated 2 times

chainWebpack: config => {
    const types = ['vue-modules', 'vue', 'normal-modules', 'normal'];

    const addFastSassLoader = rule => {
        rule
            .use('sass-loader')
            .set('loader', 'fast-sass-loader');
    };
    const scssRule = config.module.rule('scss');
    const sassRule = config.module.rule('sass');
    types.forEach(type => addFastSassLoader(scssRule.oneOf(type)));
    types.forEach(type => addFastSassLoader(sassRule.oneOf(type)));
},

[email protected] is normal,now is [email protected] vue-cli is 3.0.0-rc.11

myy012 avatar Jul 01 '19 07:07 myy012

I tried to do that but it didn't work。my CSS repeated 7 times,[email protected]

chainWebpack: config => { ['scss', 'sass'].forEach(style => { ['vue', 'vue-modules', 'normal-modules', 'normal'].forEach(one => { config.module .rule(style) .oneOf(one) .use('sass-loader') .loader('fast-sass-loader') }) }) }

ifreeWorld avatar Jul 02 '19 07:07 ifreeWorld