这个版本是基于
CRA@4和craco@6构建的. 主要是为了避免eject导致的各种问题,并且简化了项目结构. 目前这个模版仍然兼容到 IE9.
创建初始项目CRA
yarn create react-app my-react-appcd my-react-app
touch craco.config.js{
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "craco eject"
}
}yarn add craco-antd -D
yarn add antd@^3创建antd自定义样式文件. (antd@3.x 支持的自定义变量)
cd ./src
touch antd.customize.less查看
/craco.config.js
yarn add craco-less -D查看
/craco.config.js
安装插件
yarn add -D craco-plugin-style-resources-loader注意: 由于同时安装了
craco-antd, 这个插件必须配置在craco-antd的后面 查看/craco.config.js
使用 mobx@4.x
yarn add mobx@^4 mobx-react@^6允许使用装饰器
yarn add @babel/plugin-proposal-decorators -D查看
/craco.config.js
/jsconfig.json
{ "experimentalDecorators": true }yarn add react-routerbabel@7.x开始, 使用以下方式
yarn add core-js regenerator-runtime --save在./src/index.js头部引入
import 'core-js'
import 'regenerator-runtime'yarn add react-app-polyfill --save在./src/index.js头部引入
import 'react-app-polyfill/ie9'
import 'react-app-polyfill/stable'yarn add eslint -D新增配置文件: /.eslint.js,.eslintignore