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

element-plus 按需加载 公共样式 被导入多次导致编译后有大量重复代码 #28

Closed
fukai007 opened this issue Jul 24, 2021 · 3 comments

Comments

@fukai007
Copy link

element-plus 按需加载 , 我发现

@import 'common/var';
@import 'mixins/button';
@import 'mixins/mixins';
@import 'mixins/utils';

被导入多次导致编译后有大量重复代码

  css: {
    preprocessorOptions: {
      scss: {
        // additionalData: `@import "./src/assets/scss/global.scss";`,
        additionalData: `@use "./src/assets/scss/gv.scss" as *;`,
      },
    },
  },
  // plugins: [vue(), vueJsx(), babel({ extensions: ['.js', '.jsx', '.es6', '.es', '.mjs', 'ts', '.tsx'] })],
  plugins: [
    vue(),
    vueJsx(),
    styleImport({
      libs: [
        {
          libraryName: 'element-plus',
          esModule: true,
          ensureStyleFile: true,
          resolveStyle: name => {
            name = name.slice(3);
            console.log('styleImport--resolveStyle-------->', name);
            return `element-plus/packages/theme-chalk/src/${name}.scss`;
          },
          resolveComponent: name => {
            console.log('styleImport--resolveComponent-------->', name);
            return `element-plus/lib/${name}`;
          },
        },
      ],
    }),
  ],
@anncwb
Copy link
Collaborator

anncwb commented Aug 1, 2021

可以给我一个最小的复现demo吗?

1 similar comment
@anncwb
Copy link
Collaborator

anncwb commented Aug 1, 2021

可以给我一个最小的复现demo吗?

@anncwb
Copy link
Collaborator

anncwb commented Aug 1, 2021

跟 #17类似,应该不是插件问题。如果你确认是插件问题,可以提一个复现给我

@anncwb anncwb closed this as completed Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants