前言
首先为什么想到自己实现一个React脚手架呢?是因为之前刚接触create-react-app
时,觉得不太灵活。虽然文件目录很清晰,但是还是觉得不如VueCLI的可以自定义配置更加灵活。当然React官方提供了可以暴露配置的命令npm run eject
,说再多不如自己实现一个。
脚手架一览
文档
Project operation
Install
代码语言:javascript复制npm install
Start
代码语言:javascript复制npm run dev
Build
代码语言:javascript复制npm run build
Document implication
build
Webpack configuration item.
mock
Analog data.
public
Template file.
.babelrc
Babel configuration.
.gitignore
There is no need to add NPM packages.
postcss.config.js
Postcss configuration file.
src
Project home folder.
SRC folder main file
assets
Static folder.
component
Place to store components.
request
HTTP request configuration.
router
Routing configuration.
store
State management.
utils
Tool library.
view
Where the page is stored.
App.jsx
Project template.
index.js
Project entry document.
源码地址
代码语言:javascript复制https://github.com/maomincoding/ReactCli
结语
可以根据自己的需求自己再进行二次加工。欢迎Star!