5-create-react-app整合antDesign功能
使用ant-design:
首先创建react项目:
create-react-app app
cd app
其次
AntDesign的高级配置:按需导入组件,自定义主题
1.下载依赖(利用yarn,或者npm都行)
yarn add react-router-dom //装路由插件
yarn add antd //装antd 插件 在 create-react-app 创建的工程中使用 antd 组件
yarn add react-app-rewired customize-cra //react-app-rewired (一个对 create-react-app 进行自定义配置的社区解决方案)
yarn add babel-plugin-import //babel-plugin-import 是一个用于按需加载组件代码和样式的 babel 插件
yarn add less less-loader //按照 配置主题 的要求,自定义主题需要用到 less 变量覆盖功能。
2.修改package.json
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
}
- 表示要删除的
+ 表示要添加的

3,在项目根目录创建config-overrides.js
在项目根目录创建一个 config-overrides.js 用于修改默认配置。(js配置文件需要修改)
module.exports = function override(config, env) {
// do stuff with the webpack config...
return config;};

const { override, fixBabelImports, addLessLoader } = require('customize-cra');
module.exports = override(
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: { '@primary-color': '#1DA57A' },
}),
);


5-create-react-app整合antDesign功能的更多相关文章
- 如何扩展 Create React App 的 Webpack 配置
如何扩展 Create React App 的 Webpack 配置 原文地址https://zhaozhiming.github.io/blog/2018/01/08/create-react-a ...
- 深入 Create React App 核心概念
本文差点难产而死.因为总结的过程中,多次怀疑本文是对官方文档的直接翻译和简单诺列:同时官方文档很全面,全范围的介绍无疑加深了写作的心智负担.但在最终的梳理中,发现走出了一条与众不同的路,于是坚持分享出 ...
- 在 .NET Core 5 中集成 Create React app
翻译自 Camilo Reyes 2021年2月22日的文章 <Integrate Create React app with .NET Core 5> [1] Camilo Reyes ...
- tap news:week5 0.0 create react app
参考https://blog.csdn.net/qtfying/article/details/78665664 先创建文件夹 安装create react app 这个脚手架(facebook官方提 ...
- 使用create react app教程
This project was bootstrapped with Create React App. Below you will find some information on how to ...
- Create React App
Facebook开源了React前端框架(MIT Licence),也同时提供了React脚手架 - create-react-app. create-react-app遵循约定优于配置(Coc)的原 ...
- Create React App 安装less 报错
执行npm run eject 暴露模块 安装 npm i less less-loader -D 1.打开 react app 的 webpack.config.js const sassRege ...
- [React] Use the Fragment Short Syntax in Create React App 2.0
create-react-app version 2.0 added a lot of new features. One of the new features is upgrading to Ba ...
- [React] {svg, css module, sass} support in Create React App 2.0
create-react-app version 2.0 added a lot of new features. One of the new features is added the svgr ...
随机推荐
- yii components文件到底应该放些什么代码
项目全局用的代码,比如项目所有controller和model的共通操作或者放一些第三方的组件.插件之类的项目全局用的代码
- 吴裕雄 PYTHON 人工智能——基于MASK_RCNN目标检测(5)
import os import sys import numpy as np import tensorflow as tf import matplotlib import matplotlib. ...
- 【MySQL】外键的变种
" 目录 三种关系 多对一 多对多 一对一 因为有foreign key的约束,使得两张表形成了三种关系: 多对一 多对多 一对多 重点理解如何找出两张表之间的关系 现在有A.B两张表 分析 ...
- 【MySQL】常用增删改查
目录 1. 文件夹(库) 2. 文件(表) 3. 文件内容(数据) "@ ___ 1. 文件夹(库) # 增 create database db charset utf8; # 查 sho ...
- Hadoop学习2—伪分布式环境搭建
一.准备虚拟环境 1. 虚拟环境网络设置 A.安装VMware软件并安装linux环境,本人安装的是CentOS B.安装好虚拟机后,打开网络和共享中心 -> 更改适配器设置 -> 右键V ...
- 传奇GOM引擎授权过期解决方法.
传奇GOM引擎授权过期解决方法 下载最新的GOM引擎,将里面的Key.Lic文件找出来,替换掉授权过期的版本,如果你本身是免费版最好是找同样的免费版的来覆盖. 如果你本身是免费版,但是却用的是商业版K ...
- 模板元编程(Template metaprogramming)
https://en.wikipedia.org/wiki/Template_metaprogramming 没看懂...只知道了模板元编程的代码是在编译期运行的... 敲了2个例子: 1. #inc ...
- Vue-全局变量和方法
一.单文件引入 1.创建存放全局变量和方法的vue文件 Common.uve <script> const userName = 'yangjing'; function add(a,b) ...
- stl_string复习
#include <iostream>#include <string>#include <algorithm>using namespace std; void ...
- Tornado项目简单创建
Tornado是使用Python编写的一个强大的.可扩展的Web服务器.它在处理严峻的网络流量时表现得足够强健,但却在创建和编写时有着足够的轻量级,并能够被用在大量的应用和工具中. tornado技术 ...