跳至主要內容

分析組合大小

來源地圖瀏覽器使用來源地圖分析 JavaScript 組合。這有助於您瞭解程式碼膨脹的來源。

若要將來源地圖瀏覽器加入 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/*.js'",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",

然後要分析組合時,執行生產建置,然後執行分析指令碼。

npm run build
npm run analyze