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

dumi +antd 执行father build后,antd样式并没有进行打包 #537

Closed
li-yu-tfs opened this issue Oct 21, 2022 · 4 comments
Closed

Comments

@li-yu-tfs
Copy link

dumi +antd 执行father build后,antd样式和TailWindCss样式并没有进行打包,并且发布到npm库上面,下载下来,组件库的node_modules中也没有antd
image
image

@li-yu-tfs
Copy link
Author

也就是说,我如果在项目中引入该组件库,如果项目没有引入antd和tailwindcss的话,那么组件库的关于antd和tailwindcss的样式就会失效

@PeachScript
Copy link
Member

esm 是 bundless 构建、不打包是预期结果,只要产物里有引入样式,项目就会编译

关于样式打包,father 只会对 umd 产物做打包,其他都是 bundless 模式,可以在文档中查看两种模式的介绍:https://github.com/umijs/father/blob/master/docs/guide/build-mode.md

ref: #514

@PeachScript PeachScript closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2022
@li-yu-tfs
Copy link
Author

那在我的理解来说,我想在React中使用我的组件库(Antd + TailWindCss),没有解决方案了吗?

@fz6m
Copy link
Contributor

fz6m commented Oct 21, 2022

第三方组件库不应该在 dependencies 包含 antd / react 等依赖,否则会造成多实例、多倍产物问题。

正确的做法是将这些库都放到 devDependenciespeerDependencies 里:

// package.json
{
  "devDependencies": {
    "react": "",
    "antd": ""
  },
  "peerDependencies": {
    "react": "",
    "antd": ""
  }
}

该包发布到 npm 后,安装此包的项目主体在使用时,自己也必须要安装有对应的 peerDependencies 依赖,从而避免多倍产物、多实例问题。

理想情况下,第三方包应该尽量减少 dependencies 中的依赖(不会造成致命问题的除外)。

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

3 participants