32
loading...
This website collects cookies to deliver better user experience
HTML
. HTML
was the only building block of the whole web.<script>
alert("Welcome to my website")
</script>
const example = 10;
var e = 10;
Entry - the entry destination is the main file we want Webpack to start its bundling. We only have to specify one file and Webpack will figure out the rest by looking for its dependencies. Here we specify the index.js file which is the place where we render our App in React (and all other files are just siblings of it).
Output - is the path where we want our bundle to be. We specify directory name (here it's dist) and we can also specify the file name we want to output.
Loaders - Webpack is not very smart. It understands only JS and JSON files. If we want Wepback to understand JSX, for example, we have to specify loaders that will translate it for Webpack. Here we specify the babel-loader and set its options to work with JSX (React).
Plugins - These help us to make our code more optimized and handle assets. In our example, we use the HtmlWebpackPlugin. This plugin will generate an HTML file and will automatically inject our JS bundle into it.
For more posts like this follow me on LinkedIn
I work as frontend & content developer for Bit - a toolchain for component-driven development (Forget monolithic apps and distribute to component-driven software).