...

/

Adding Webpack

Adding Webpack

In this lesson, we'll continue to set up our React and TypeScript project by adding a tool that will bundle the code together.

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 ...