An ejected create-react-app application for demonstrating more advanced webpack configuration.
Explanation in this blog: Caching Assets Long Term with Webpack
npm i
Each step is tagged so that it's easy to check out the tutorial at any step by using:
git checkout [TAG]
To see the changes made between tags:
git diff [TAG_1]..[TAG_2]
Here are the tags in chronological order:
- The default app generated by react-create-app
- The app after ejecting react-create-app:
npm run eject
- Adds a simple Express server for serving the production build.
- Seperate app and vendor assets using Webpack
CommonsChunkPlugin
.
- Use
CommonsChunkPlugin
to generate a seperate manifest.js including the Webpack runtime as well as the chunk mapping. - Configure html-webpack-plugin to order assets correctly in the production build.
- Use inline-manifest-webpack-plugin to inline manifest.js in the html.
- Use Webpack NamedModulesPlugin to use deterministic module names instead of non-deterministic integer ids.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
Runs the app in production mode. The build step is run automatically before starting the app via a npm pre command.
Open http://localhost:9000 to view in the browser.