Adding Webpack
Explore the process of manually setting up Webpack for a React and TypeScript project. Understand how to install required Webpack packages, configure loaders for TypeScript and React code, set up the development server, and integrate type checking with ForkTsCheckerWebpackPlugin. This lesson equips you to bundle and serve your app effectively while ensuring type safety during development.
Installing Webpack
Webpack is a popular tool that we can use to bundle all our JavaScript code into the bundle.js file that our index.html is expecting. Let’s install the core webpack library as well as its command-line interface:
npm install --save-dev webpack webpack-cli
TypeScript types are included in the webpack package, so we don’t need to install them separately.
Webpack has a web server that we will use during development. Let’s install this:
npm install --save-dev webpack-dev-server @types/webpack-dev-server
TypeScript types aren’t included in the webpack-dev-server package, which is why we installed the @types/webpack-dev-server package.
Why do you think we installed these Webpack dependencies as development dependencies?
Installing Webpack Babel and ESLint plugins #
We need a webpack plugin, babel-loader, to allow Babel to transpile the React and ...