Antd在create-react-app中对自定义主题的设置的问题
来源:互联网 发布:云计算培训有前途吗 编辑:程序博客网 时间:2024/05/18 11:29
最近笔者开始研究起了react.js。不得不说虽然语法和react-native差不多,但是redux,还是等等之类的东西接受起来还是有些挑战的.
今天笔者看起了react的ui库:antd,在碰到自定义主题的时候遇上了bug,按照教程一步步做下来却没有作用。下面附上官方doc中的有问题的地方。
const { injectBabelPlugin } = require('react-app-rewired'); const rewireLess = require('react-app-rewire-less'); module.exports = function override(config, env) { - config = injectBabelPlugin(['import', { libraryName: 'antd', style: 'css' }], config); + config = injectBabelPlugin(['import', { libraryName: 'antd', style: true }], config); + config = rewireLess(config, env, { modifyVars: { "@primary-color": "#1DA57A" }, }); return config; };
百度了一半天,最后我在其他脚手架里的源码发现了问题所在,原因是格式出错了。
config = injectBabelPlugin(['import', { libraryName: 'antd', style: true }], config); config = rewireLess.withLoaderOptions({ modifyVars: { "@primary-color": "#1DA57A" }, })(config, env); //要这样写才行。。
当然不得不提的还有react-app-rewire-less
这个库的bug,居然会有语法错误。。我也不知道是怎么回事, 2.0.8 中需要删除一个逗号才能正常使用。这个库的编写者很粗心啊。。。 不过当笔者在github上准备交一发的时候发现已经有相关的pull request 等待合并了,所以呢,这个问题等你们看到这篇的时候应该已经fix了~
阅读全文
0 0
- Antd在create-react-app中对自定义主题的设置的问题
- 在react-native中引入antd-mobile遇到的问题
- create-react-app方式下引入antd
- create-react-app + antd-mobile配置
- Create-react-app+Antd+Less配置
- webpack+react+antd项目编写过程中遇到的问题
- webpack react antd遇到的问题
- Create-React-App创建antd-mobile开发环境
- Create-React-App创建antd-mobile开发环境
- 使用Create-React-App脚手架创建antd-mobile开发环境
- react-create-app打包过程遇到的问题
- create-react-app my-appcreate-react-app慢的解决方法
- create-react-app慢的解决方法
- 升级Create React App的项目
- create-react-app路由的实现原理
- react项目的组件库antd-mobile
- react配置antd的按需加载。
- 开发 react 应用最好用的脚手架 create-react-app
- JAVA集合框架之List Set接口
- 11-02
- 用户注册入库
- 2017-11-2 两天的总结
- C#基础点滴_enum
- Antd在create-react-app中对自定义主题的设置的问题
- suse 11.4安装11.2.0.3 oracle rac并用swingbench进行性能测试
- codeforces 551E GukiZ and GukiZiana 分块
- butterknife及其背后的代码生成技术
- C练习题-(三)
- 2017年11月02日作业
- 图像识别与处理之Opencv——高斯滤波及GaussianBlur()函数
- el和jstl笔记
- IDEA implement interface 不小心 disable 解决方案