至少对于我来说,我认为 react 脚手架应该是纯透明的,虽然可能暴露出过多配置项对新人不友好,但封装成黑盒后更改更费力。 在 github 上搜了好久,都没搜到透明的脚手架,基于此想法创建仓库 https://github.com/toy-playground/react-cli-with-ts 希望共建,或者提出宝贵建议!
1
LOWINC 2021-08-06 08:53:13 +08:00 2
[craco]( https://github.com/gsoft-inc/craco) 不是蛮好用的吗
|
2
kinghly 2021-08-06 09:20:30 +08:00
你这个是项目模板,称不上 cli 。用 CRA 的话,可以用楼上说的 craco 覆盖 webpack 配置。
|
3
zuobinwang OP @LOWINC !!感谢告知
|
4
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. |