1

前端相关技巧

 2 years ago
source link: https://www.jansora.com/notebook/88
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

分析 Bundle (包) 大小

Source map explorer 使用 source maps 分析 JavaScript 包。 这有助于你了解代码膨胀的来源。

要将 Source map explorer 添加到 Create React App 项目,请按照下列步骤操作:

npm install --save source-map-explorer
或者你可以使用 yarn:

yarn add source-map-explorer

然后在 package.json 中,将以下行添加到 scripts 中:

   "scripts": {
+    "analyze": "source-map-explorer build/static/js/main.*",
     "start": "react-scripts start",
     "build": "react-scripts build",
     "test": "react-scripts test",
     }

然后分析 bundle(包) 运行生产构建然后运行分析脚本。

npm run build
npm run analyze

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK