简体   繁体   English

ReactJs 中的 Webpack 警告

[英]Webpack warning in ReactJs

Can anyone please explain, why I am getting this warning after npm start ?谁能解释一下,为什么我在npm 启动后收到此警告?

Here's my package.json这是我的 package.json

{
  "name": "rou-lesson",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Here's a warning from webpack and I am getting this message all time after npm start.这是来自 webpack 的警告,我在 npm 启动后一直收到此消息。

enter image description here在此处输入图像描述

after npm start npm启动后

You can now view rou-lesson in the browser.您现在可以在浏览器中查看 rou-lesson。

Local: http://localhost:3000本地:http://localhost:3000
On Your Network: http://192.168.0.103:3000在您的网络上: http://192.168.0.103:3000

Note that the development build is not optimized.请注意,开发版本未优化。 To create a production build, use npm run build.要创建生产构建,请使用 npm 运行构建。

> assets by path static/ 1.52 MiB   asset static/js/bundle.js 1.51 MiB
> [emitted] (name: main) 1 rela   asset
> static/js/node_modules_web-vitals_dist_web-vitals_js.chunk   asset
> static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg 2.5 asset
> index.html 1.67 KiB [emitted] asset asset-manifest.json 546 bytes
> [emitted] runtime modules 31.4 KiB 16 modules modules by path
> ./node_modules/ 1.38 MiB 95 modules modules by path ./src/ 18.1 KiB  
> modules by path ./src/*.css 8.82 KiB
>     ./src/index.css 2.72 KiB [built] [code generated]
>     ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].ones??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-lode
> generated]
>     ./src/App.css 2.72 KiB [built] [code generated]
>     ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].ones??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-lenerated]
> modules by path ./src/*.js 5.71 KiB  KiB [built] [code generated]
> webpack 5.65.0 compiled successfully in 12201 ms

When you type "npm starts" in command line, webpack runs your code as "development" mode which means webpack doesn't optimize your code and run it in memory to run faster(it doesn't make optimized files as rusult in "development mode").当您在命令行中键入“npm 启动”时,webpack 将您的代码作为“开发”模式运行,这意味着 webpack 不会优化您的代码并在 memory 中运行它以使优化的文件在“开发”中运行得更快模式”)。 Webpack optimize your files when you run it as "production" mode. Webpack 当您以“生产”模式运行时优化您的文件。 If you type "npm run build", webpack optimize all your code and make it some bundled files as a rusult.如果您键入“npm run build”,webpack 会优化您的所有代码,并将其作为一些捆绑文件。 I think that message is just a warning message that webpack throw to remind user this automatically我认为该消息只是 webpack 抛出以自动提醒用户的警告消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM