【问题标题】:Disable Babel compilation details in create-react-app 5.0.0在 create-react-app 5.0.0 中禁用 Babel 编译细节
【发布时间】:2022-01-05 16:59:20
【问题描述】:

react-scripts(Create React App)更新到5.0.0后,在终端运行npm start命令时,会增加一堆编译日志:

Compiled successfully!

You can now view product-list-dashboard in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.1.2:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

assets by status 1.1 KiB [cached] 1 asset
assets by chunk 1.63 MiB (name: main)
  asset static/js/bundle.js 1.62 MiB [emitted] (name: main) 1 related asset
  asset main.7ab1960ed887a618980d.hot-update.js 11.3 KiB [emitted] [immutable] [hmr] (name: main) 1 related asset
assets by path *.json 431 bytes
  asset asset-manifest.json 403 bytes [emitted]
  asset main.7ab1960ed887a618980d.hot-update.json 28 bytes [emitted] [immutable] [hmr]
asset index.html 376 bytes [emitted]
Entrypoint main 1.63 MiB (1.55 MiB) = static/js/bundle.js 1.62 MiB main.7ab1960ed887a618980d.hot-update.js 11.3 KiB 3 auxiliary assets
cached modules 1.41 MiB [cached] 127 modules
runtime modules 28.2 KiB 13 modules
javascript modules 7.33 KiB
  ./src/App.js 5.58 KiB [built] [code generated]
  ./src/productList.js 1.75 KiB [built] [code generated]
webpack 5.65.0 compiled successfully in 522 ms

react-scripts 版本 4 中未观察到此行为。是否有机会从终端中删除此信息?

【问题讨论】:

  • CRA 通常不可配置。如果您不喜欢开箱即用的内容,则必须向维护人员提出更改,使用诸如 craco 之类的库来修改它,或者弹出并应用您所做的更改想要自己。
  • Craco 不支持 CRA5,至少现在还不行。

标签: javascript node.js reactjs babeljs create-react-app


【解决方案1】:

在修改 CRA 设置后,我发现了一个肮脏的 hack,可以再次清理控制台 - 转到 node_modules/react-scripts/config/webpack.config.js 并在配置对象的最后添加 stats: none。这将带回老式的终端开发日志,而没有那些 web 包块垃圾

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-24
    • 1970-01-01
    • 2018-06-06
    • 2020-10-11
    • 2018-11-26
    • 2021-10-11
    • 2019-10-29
    相关资源
    最近更新 更多