mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-03-29 00:18:13 +08:00
Move analyzing the bundle size into its own file
This commit is contained in:
39
docusaurus/docs/analyzing-the-bundle-size.md
Normal file
39
docusaurus/docs/analyzing-the-bundle-size.md
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
id: analyzing-the-bundle-size
|
||||
title: Analyzing the Bundle Size
|
||||
sidebar_label: Analyzing bundle size
|
||||
---
|
||||
|
||||
[Source map explorer](https://www.npmjs.com/package/source-map-explorer) analyzes
|
||||
JavaScript bundles using the source maps. This helps you understand where code
|
||||
bloat is coming from.
|
||||
|
||||
To add Source map explorer to a Create React App project, follow these steps:
|
||||
|
||||
```sh
|
||||
npm install --save source-map-explorer
|
||||
```
|
||||
|
||||
Alternatively you may use `yarn`:
|
||||
|
||||
```sh
|
||||
yarn add source-map-explorer
|
||||
```
|
||||
|
||||
Then in `package.json`, add the following line to `scripts`:
|
||||
|
||||
```diff
|
||||
"scripts": {
|
||||
+ "analyze": "source-map-explorer build/static/js/main.*",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
```
|
||||
|
||||
Then to analyze the bundle run the production build then run the analyze
|
||||
script.
|
||||
|
||||
```
|
||||
npm run build
|
||||
npm run analyze
|
||||
```
|
||||
@@ -54,7 +54,6 @@ You can find the most recent version of this guide [here](https://github.com/fac
|
||||
- [Why Opt-in?](#why-opt-in)
|
||||
- [Offline-First Considerations](#offline-first-considerations)
|
||||
- [Progressive Web App Metadata](#progressive-web-app-metadata)
|
||||
- [Analyzing the Bundle Size](#analyzing-the-bundle-size)
|
||||
- [Advanced Configuration](#advanced-configuration)
|
||||
- [Alternatives to Ejecting](#alternatives-to-ejecting)
|
||||
|
||||
@@ -1119,42 +1118,6 @@ work offline when there's an active service worker. That being said, the
|
||||
metadata from the web app manifest will still be used regardless of whether or
|
||||
not you opt-in to service worker registration.
|
||||
|
||||
## Analyzing the Bundle Size
|
||||
|
||||
[Source map explorer](https://www.npmjs.com/package/source-map-explorer) analyzes
|
||||
JavaScript bundles using the source maps. This helps you understand where code
|
||||
bloat is coming from.
|
||||
|
||||
To add Source map explorer to a Create React App project, follow these steps:
|
||||
|
||||
```sh
|
||||
npm install --save source-map-explorer
|
||||
```
|
||||
|
||||
Alternatively you may use `yarn`:
|
||||
|
||||
```sh
|
||||
yarn add source-map-explorer
|
||||
```
|
||||
|
||||
Then in `package.json`, add the following line to `scripts`:
|
||||
|
||||
```diff
|
||||
"scripts": {
|
||||
+ "analyze": "source-map-explorer build/static/js/main.*",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
```
|
||||
|
||||
Then to analyze the bundle run the production build then run the analyze
|
||||
script.
|
||||
|
||||
```
|
||||
npm run build
|
||||
npm run analyze
|
||||
```
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
You can adjust various development and production settings by setting environment variables in your shell or with [.env](#adding-development-environment-variables-in-env).
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"lint-output-in-the-editor",
|
||||
"debugging-in-the-editor",
|
||||
"formatting-code-automatically",
|
||||
"proxying-api-requests-in-development"
|
||||
"proxying-api-requests-in-development",
|
||||
"analyzing-the-bundle-size"
|
||||
],
|
||||
"Testing": ["running-tests", "debugging-tests"],
|
||||
"Deployment": ["publishing-components-to-npm", "deployment"],
|
||||
|
||||
Reference in New Issue
Block a user