Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily remove doc section on webpack analyzer #4564

Merged
merged 1 commit into from
Jun 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2048,14 +2048,6 @@ will affect your users' experience.

## Analyzing the Bundle Size

When your app grows in size, it's easy for bundles to become bloated. The first step to solving large bundles is understanding what's in them!

There are many different tools available to analyze bundles, but they typically rely on either **sourcemaps** or **webpack-specific JSON stats**.

### Using Sourcemaps

When building for production, sourcemaps are automatically created adjacent to the JS files in `build/static/js`.

[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.
Expand Down Expand Up @@ -2090,45 +2082,6 @@ npm run build
npm run analyze
```

### Using Webpack Stats JSON

> Note: this feature is available with [email protected] and higher.

Webpack can produce a JSON manifest that details the bundles, and several tools can use that file to do analysis.

Unlike with sourcemaps, the JSON file isn't created automatically on build. You must pass a `--stats` flag:

```sh
npm run build -- --stats
```

Once the build is complete, you should have a JSON file located at `build/bundle-stats.json`.

The quickest way to get insight into your bundle is to drag and drop that JSON file into [Webpack Visualizer](https://chrisbateman.github.io/webpack-visualizer/).

Another very popular tool is [`webpack-bundle-analyzer`](https://github.com/webpack-contrib/webpack-bundle-analyzer).

To use `webpack-bundle-analyzer`, start by installing it from NPM:

```sh
npm install --save webpack-bundle-analyzer
# or, with Yarn:
yarn add webpack-bundle-analyzer
```


In `package.json`, add the following line to `scripts`:

```diff
"scripts": {
+ "analyze": "npm run build -- --stats && webpack-bundle-analyzer build/bundle-stats.json",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
```

When you run `npm run analyze`, a new build will be created, and a browser tab should open automatically, displaying the sizes of the modules within your bundle.

## Deployment

`npm run build` creates a `build` directory with a production build of your app. Set up your favorite HTTP server so that a visitor to your site is served `index.html`, and requests to static paths like `/static/js/main.<hash>.js` are served with the contents of the `/static/js/main.<hash>.js` file.
Expand Down