cra-template-ant-concent v1.2.1
cra-template-ant-concent
๐ A react template, based on creact-react-app, support antd demand importing, concent, less, decorator, webpack aliasใ
๐ Happy coding!!!
Start
- create procjet
# if you had installed cra as global module
$ create-react-app your-project-name --template ant-concent
# or use npx
$ npx create-react-app your-project-name --template ant-concent- start project
$ npm startWait a moment, you can see your site on http://localhost:3000.
Config
mobile config
remove antd and install antd-mobile
$ npm uninstall antd
$ npm install antd-mobile -S
# if you use yarn
$ yarn remove antd
$ yarn add antd-mobilemodify craco.config.js, change antd to antd-mobile in libraryName.
Attention: if you don't use
antd-mobile, you could removebabel-plugin-importdirectly.
modify webpack alias
See craco.config.js and jsconfig.json, modify them correspondingly.
modify devServer port
modify start script in package.json start like this๏ผ
{
"scripts": {
"start": "cross-env PORT=4000 craco start"
}
}add source map for build
remove env variable in build script in package.json GENERATE_SOURCEMAP=false.
set proxy for devServer
See src/setupProxy.js.
config webpack, babel or eslint
We use craco to customize webpack, babel, eslint. Read offical document to get addvanced usages.
router config
We draw lessons from convention routing of umi for router rendering, most of them are same but still have a number of different:
- No SSR, we eliminate that part of code
- We use
React.lazy()to Wrapp a page component - Add
titlekey to modify page title - Default props for
<Route />is different, seedefaultRoutePropsinsrc/router/renderRoutes.js.
Feature
- antd/antd-mobile demand importing
- less
- decorator
- webpack alias and VSCode support
- custom webpack, eslint, babel config
- react demand loading and code splitting
- eslint check
- git hooks check
- concent demo codes
- ts support
- mock support
LICENSE
MIT