arco-design / arco-design-pro

An out-of-the-box solution to quickly build enterprise-level applications based on Arco Design.
https://pro.arco.design
MIT License
485 stars 95 forks source link

vitePluginForArco 设置 style 为 false 的时候 不会按需导入组件了 #107

Open mtrucc opened 1 year ago

mtrucc commented 1 year ago

Basic Info

Extra info

使用 https://arco.design/vue/docs/pro/start 快速创建 vue 版本 修改 config/plugin/arcoStyleImport.ts 文件

export default function configArcoStyleImportPlugin() {
  const arcoResolverPlugin = vitePluginForArco({
    style: false,
  });
  return arcoResolverPlugin;
}

What is expected?

设置 style 为 false 的时候,按需导入组件,但不导入对应样式。

Steps to reproduce

export default function configArcoStyleImportPlugin() {
  const arcoResolverPlugin = vitePluginForArco({
    style: false,
  });
  return arcoResolverPlugin;
}
mtrucc commented 1 year ago

https://github.com/arco-design/arco-plugins/blob/3a092eea4307b17cfdc2ab091906d6ab60a7f43e/packages/plugin-vite-vue/src/arco-design-plugin/transform.ts#L68

  if (style === false || !/\.(js|jsx|ts|tsx|vue)$/.test(id)) {
    return undefined;
  }

这种判断方式是不是有问题?