Webpack Configuration and Server
Explore how to configure Webpack to build example React applications and set up webpack-dev-server for fast local development. Understand how to create entry points, generate HTML pages automatically, and enable hot module reloading for efficient testing and styling workflows.
We'll cover the following...
Adding an Example Page
-
Create an
exampledir. Since it will contain web app code, it should be based on the same ESLint config as thesrcdir. However, one adjustment is in order. As it is, the linter will complain any time we return JSX from a function if that function doesn’t declare its arguments aspropTypes. This is a bit of a nuisance, so disable thereact/prop-typesrule within theexampledir://.eslintrc.js module.exports = { env: { browser: true, }, rules: { "react/prop-types": "off", } };
-
We need a page to host this app. Rather than writing up the HTML, you can make webpack generate it as part of the build process using
html-webpack-plugin:$ npm install --save-dev html-webpack-plugin@3.2.0 + html-webpack-plugin@3.2.0