Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !3928

Add new script to generate `bundle-stats.json`.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/joshwcomeau/bundle-stats into next Jan 28, 2018
  • Overview 5
  • Commits 27
  • Pipelines 0
  • Changes 35

Created by: joshwcomeau

As discussed in #1858 (closed), we want to generate a JSON stats object from Webpack, so that folks can use popular tools like webpack-bundle-analyzer without ejecting.

This change adds a new script: build:with-stats. This new script does exactly the same thing as build, but with the added work of generating build/bundle-stats.json, using bfj to create a write stream.

Test plan:

1. check that the build script works

I ran yarn build:with-stats in the root directory of the project. Once it completed, I verified that build/bundle-stats.json existed. I dragged it into Webpack Visualizer to check that the file is correct

2. check that it creates the new script

I ran yarn create-react-app test to generate a new app. I checked that the new script is documented in that initial echo:

screen shot 2018-01-28 at 1 00 06 pm

I ran cd test, and then yarn build:with-stats. Similarly, I verified that the file was created in build/bundle-stats.json.

3. check the instructions for webpack-bundle-analyzer

In the new README, I added steps for using with webpack-bundle-analyzer. I verified that they work by:

  • running yarn add webpack-bundle-analyzer
  • copying this line to package.json: "analyze": "npm run build:with-stats && webpack-bundle-analyzer build/bundle-stats.json",
  • running yarn analyze

After building, it automatically opened a browser window:

screen shot 2018-01-28 at 12 54 11 pm
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/joshwcomeau/bundle-stats