Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

假如样式文件不存在 #4

Closed
carlosyan1807 opened this issue Feb 23, 2021 · 3 comments
Closed

假如样式文件不存在 #4

carlosyan1807 opened this issue Feb 23, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@carlosyan1807
Copy link

很方便的插件!

ep adv的每个组件都有样式文件,工作正常
假如自写组件库或者其他第三方的库中某个组件没有样式文件,会报错
是否可以加个类似这样的设置,即使单个样式文件不存在也可以跑起来,不会中断整个vite

// vite.config.js

export default defineConfig({
  plugins: [
    vue(),
    styleImport({
      libs: [
        {
          libraryName: 'my-components',
          throwNotFound: false,
          resolveStyle: (name) => `my-components/dist/${name}/style.css` ,
        },
      ]
    })
  ]
})

image
image

附现在练习项目打包前后的目录
image

打包后
image

@anncwb
Copy link
Collaborator

anncwb commented Feb 24, 2021

组件库一般都是规范的。基本都存在,就算不存在,在resolveStyle下面也可以通过自己写逻辑来判断。不过我会在下个版本加个判断,来解决这个问题

@anncwb anncwb added the enhancement New feature or request label Feb 24, 2021
@carlosyan1807
Copy link
Author

又看了下ep打包后的文件,其中 el-menu-item.css el-menu-item-group.css el-submenu.css el-infinite-scroll.css el-button-goup.css el-breadcrumb-item.css el-tab-pane.css 都是空文件,之前表达不够清楚,就是开发组件的实际情况中确实有不需要样式文件的可能性,比如子组件,我想这个插件不应该只支持主流大厂的组件库,应用范围可以更广泛,哈哈,当然,ep为了统一性打包时输出了该组件名称的空样式文件,我去改改我rollup的配置文件,把空的也输出出来就好啦。

@anncwb
Copy link
Collaborator

anncwb commented Feb 24, 2021

增加了 ensureStyleFile配置。配置成 true可以解决这个。升级到0.7.5即可

@anncwb anncwb closed this as completed Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants