react cli

2021-08-05 22:05:26 +08:00
 zuobinwang

至少对于我来说,我认为 react 脚手架应该是纯透明的,虽然可能暴露出过多配置项对新人不友好,但封装成黑盒后更改更费力。 在 github 上搜了好久,都没搜到透明的脚手架,基于此想法创建仓库 https://github.com/toy-playground/react-cli-with-ts 希望共建,或者提出宝贵建议!

1531 次点击
所在节点    分享创造
4 条回复
LOWINC
2021-08-06 08:53:13 +08:00
[craco]( https://github.com/gsoft-inc/craco) 不是蛮好用的吗
kinghly
2021-08-06 09:20:30 +08:00
你这个是项目模板,称不上 cli 。用 CRA 的话,可以用楼上说的 craco 覆盖 webpack 配置。
zuobinwang
2021-08-06 09:52:42 +08:00
@LOWINC !!感谢告知
vone
2021-08-10 10:57:30 +08:00
你是否是在说 create-react-app 创建的项目封装了 webpack 、Babel 、ESLint 这些工具。
如果是的话,你可以在初始化运行:

npm run eject


具体文档见: https://create-react-app.dev/docs/available-scripts#npm-run-eject


## npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc.) into your project as dependencies in package.json. Technically, the distinction between dependencies and development dependencies is pretty arbitrary for front-end apps that produce static bundles.

In addition, it used to cause problems with some hosting platforms that didn't install development dependencies (and thus weren't able to build the project on the server or test it right before deployment). You are free to rearrange your dependencies in package.json as you see fit.

All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/793949

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX