webpack 分析工具

运行这个命令会得到如下

npx webpack --json > stats.json

{
  "hash": "9a4643c4dc5d290a8158",
  "version": "5.35.0",
  "time": 200,
  "builtAt": 1621943691060,
  "publicPath": "auto",
  "outputPath": "D:\\MandyGit\\WEBPACK5\\dist",
  "assetsByChunkName": { "main": ["main.js"] },
  "assets": [
    {
      "type": "asset",
      "name": "main.js",
      "size": 0,
      "emitted": false,
      "comparedForEmit": false,
      "cached": true,
      "info": { "javascriptModule": false, "minimized": true },
      "chunkNames": ["main"],
      "chunkIdHints": [],
      "auxiliaryChunkNames": [],
      "auxiliaryChunkIdHints": [],
      "related": {},
      "chunks": [179],
      "auxiliaryChunks": [],
      "isOverSizeLimit": false
    }
  ],
  "chunks": [
    {
      "rendered": true,
      "initial": true,
      "entry": true,
      "recorded": false,
      "size": 0,
      "sizes": {},
      "names": ["main"],
      "idHints": [],
      "runtime": ["main"],
      "files": ["main.js"],
      "auxiliaryFiles": [],
      "hash": "db04cd3e8195716d3f4c",
      "childrenByOrder": {},
      "id": 179,
      "siblings": [],
      "parents": [],
      "children": [],
      "modules": [],
      "origins": [
        {
          "module": "",
          "moduleIdentifier": "",
          "moduleName": "",
          "loc": "main",
          "request": "./src"
        }
      ]
    }
  ],
  "modules": [],
  "entrypoints": {
    "main": {
      "name": "main",
      "chunks": [179],
      "assets": [{ "name": "main.js" }],
      "filteredAssets": 0,
      "assetsSize": null,
      "auxiliaryAssets": [],
      "filteredAuxiliaryAssets": 0,
      "auxiliaryAssetsSize": 0,
      "children": {},
      "childAssets": {},
      "isOverSizeLimit": false
    }
  },
  "namedChunkGroups": {
    "main": {
      "name": "main",
      "chunks": [179],
      "assets": [{ "name": "main.js" }],
      "filteredAssets": 0,
      "assetsSize": null,
      "auxiliaryAssets": [],
      "filteredAuxiliaryAssets": 0,
      "auxiliaryAssetsSize": 0,
      "children": {},
      "childAssets": {},
      "isOverSizeLimit": false
    }
  },
  "errors": [
    {
      "loc": "main",
      "message": "Module not found: Error: Can't resolve './src' in 'D:\\MandyGit\\WEBPACK5'",
      "details": "resolve './src' in 'D:\\MandyGit\\WEBPACK5'\n  using description file: D:\\MandyGit\\WEBPACK5\\package.json (relative path: .)\n    Field 'browser' doesn't contain a valid alias configuration\n    using description file: D:\\MandyGit\\WEBPACK5\\package.json (relative path: ./src)\n      no extension\n        Field 'browser' doesn't contain a valid alias configuration\n        D:\\MandyGit\\WEBPACK5\\src is not a file\n      .js\n        Field 'browser' doesn't contain a valid alias configuration\n        D:\\MandyGit\\WEBPACK5\\src.js doesn't exist\n      .json\n        Field 'browser' doesn't contain a valid alias configuration\n        D:\\MandyGit\\WEBPACK5\\src.json doesn't exist\n      .wasm\n        Field 'browser' doesn't contain a valid alias configuration\n        D:\\MandyGit\\WEBPACK5\\src.wasm doesn't exist\n      as directory\n        existing directory D:\\MandyGit\\WEBPACK5\\src\n          using description file: D:\\MandyGit\\WEBPACK5\\package.json (relative path: ./src)\n            using path: D:\\MandyGit\\WEBPACK5\\src\\index\n              using description file: D:\\MandyGit\\WEBPACK5\\package.json (relative path: ./src/index)\n                no extension\n                  Field 'browser' doesn't contain a valid alias configuration\n                  D:\\MandyGit\\WEBPACK5\\src\\index doesn't exist\n                .js\n                  Field 'browser' doesn't contain a valid alias configuration\n                  D:\\MandyGit\\WEBPACK5\\src\\index.js doesn't exist\n                .json\n                  Field 'browser' doesn't contain a valid alias configuration\n                  D:\\MandyGit\\WEBPACK5\\src\\index.json doesn't exist\n                .wasm\n                  Field 'browser' doesn't contain a valid alias configuration\n                  D:\\MandyGit\\WEBPACK5\\src\\index.wasm doesn't exist",
      "stack": "ModuleNotFoundError: Module not found: Error: Can't resolve './src' in 'D:\\MandyGit\\WEBPACK5'\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\Compilation.js:1735:28\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\NormalModuleFactory.js:726:13\n    at eval (eval at create (D:\\MandyGit\\WEBPACK5\\node_modules\\tapable\\lib\\HookCodeFactory.js:33:10), <anonymous>:8:1)\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\NormalModuleFactory.js:273:22\n    at eval (eval at create (D:\\MandyGit\\WEBPACK5\\node_modules\\tapable\\lib\\HookCodeFactory.js:33:10), <anonymous>:7:1)\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\NormalModuleFactory.js:402:22\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\NormalModuleFactory.js:117:11\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\NormalModuleFactory.js:642:24\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\NormalModuleFactory.js:796:8\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\NormalModuleFactory.js:916:5"
    }
  ],
  "errorsCount": 1,
  "warnings": [
    {
      "message": "configuration\nThe 'mode' option has not been set, webpack will fallback to 'production' for this value.\nSet 'mode' option to 'development' or 'production' to enable defaults for each environment.\nYou can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/",
      "stack": "NoModeWarning: configuration\nThe 'mode' option has not been set, webpack will fallback to 'production' for this value.\nSet 'mode' option to 'development' or 'production' to enable defaults for each environment.\nYou can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\WarnNoModeSetPlugin.js:20:30\n    at Hook.eval [as call] (eval at create (D:\\MandyGit\\WEBPACK5\\node_modules\\tapable\\lib\\HookCodeFactory.js:19:10), <anonymous>:19:1)\n    at Hook.CALL_DELEGATE [as _call] (D:\\MandyGit\\WEBPACK5\\node_modules\\tapable\\lib\\Hook.js:14:14)\n    at Compiler.newCompilation (D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\Compiler.js:1016:30)\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\Compiler.js:1059:29\n    at Hook.eval [as callAsync] (eval at create (D:\\MandyGit\\WEBPACK5\\node_modules\\tapable\\lib\\HookCodeFactory.js:33:10), <anonymous>:4:1)\n    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\\MandyGit\\WEBPACK5\\node_modules\\tapable\\lib\\Hook.js:18:14)\n    at Compiler.compile (D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\Compiler.js:1054:28)\n    at D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\Compiler.js:494:12\n    at Compiler.readRecords (D:\\MandyGit\\WEBPACK5\\node_modules\\webpack\\lib\\Compiler.js:894:11)"
    }
  ],
  "warningsCount": 1,
  "children": []
}
  • 「assets」 :编译最终输出的产物列表

  • 「chunks」 :构建过程生成的 chunks 列表,数组内容包含 chunk 名称、大小、依赖关系图

  • 「modules」 :本次运行触达的所有模块,数组内容包含模块的大小、所属chunk、分析耗时、构建原因等

  • 「entrypoints」 :entry 列表,包括动态引入所生产的 entry 项也会包含在这里面

  • 「namedChunkGroups」 :chunks 的命名版本,内容相比于 chunks 会更精简

  • 「errors」 :构建过程发生的所有错误信息

  • 「warnings」 :构建过程发生的所有警告信息

     基于这些属性,我们可以分析出模块的依赖关系、模块占比、编译耗时等信息,不过这个貌似也没啥用大大用 只是知道就行  可以看看 

 

还有其他的分析工具可以用

Webpack Visualizer

使用方式

npm install webpack-visualizer-plugin

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值