father + dumi 引用antd 某些组件,打包后,在项目中引用的问题!!
例如: 在组件库中引用了antd的DatePicker组件,并在fatherrc.ts 中配置了 ` extraBabelPlugins: [ [ 'babel-plugin-import', { libraryName: 'antd', libraryDirectory: 'es', style: true, }, 'antd' ] ], lessInRollupMode: { modifyVars: { '@primary-color': '#CC0014', } }
`
在项目中使用 时,还需要在项目中配置才能生效样式文件, 以react-app-rewired 和 customize-cra 为例
` webpack: override( fixBabelImports('import', { libraryName: 'antd', libraryDirectory: 'es', style: true, }), ... ),
` 如果需要在项目中再次配置,那么组件库中的.fatherrc.ts 的配置意义何在呢?
我的问题是: 如何可以直接在组件库中配置打包好样式,无需在项目中再次配置按需引入,可以直接使用呢? 谢谢!
你主动在组件库里面引入对应的样式,不使用 babel-plugin-import 不就行了吗?
例如
import { Input } from 'antd';
import 'antd/es/input/style';
......
father 4 已发布,可尝试升级到最新版:https://github.com/umijs/father/blob/master/docs/guide/migrate.md
旧版本不再维护,感谢支持