Now, webpack is one of many modular tools that can be used in your program. Additionally, unlike React scripts, it has use outside of React: it can be used as a bundler for many different types of applications. To get our hands dirty, let's create a small, useless sample project:
- Create a new directory and navigate into it: mkdir webpack-example ; cd webpack-example.
- We'll be using NPM, so we need to initialize it. We'll also accept the defaults: npm init -y.
- We have to then install webpack: npm install webpack webpack-cli --save-dev.
Note that we're using --save-dev here because we don't need webpack to be built into our production-level files. By using dev dependencies, we can help reduce our bundle size, a factor that can slow down applications if it bloats.
If you look in the node_modules directory here, you'll see that we've already installed over 3.5 thousand files from our dependencies. Our project is fairly boring as it...