V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
zuobinwang
V2EX  ›  分享创造

react cli

  •  
  •   zuobinwang ·
    Dreamerryao · 2021-08-05 22:05:26 +08:00 · 1530 次点击
    这是一个创建于 1204 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    4 条回复    2021-08-10 10:57:30 +08:00
    LOWINC
        1
    LOWINC  
       2021-08-06 08:53:13 +08:00   ❤️ 2
    [craco]( https://github.com/gsoft-inc/craco) 不是蛮好用的吗
    kinghly
        2
    kinghly  
       2021-08-06 09:20:30 +08:00
    你这个是项目模板,称不上 cli 。用 CRA 的话,可以用楼上说的 craco 覆盖 webpack 配置。
    zuobinwang
        3
    zuobinwang  
    OP
       2021-08-06 09:52:42 +08:00 via iPhone
    @LOWINC !!感谢告知
    vone
        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.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2811 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 13:56 · PVG 21:56 · LAX 05:56 · JFK 08:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.