Abdu Taviq

Webpack Tutorial

YouTube Video

Just Enough webpack 5 tutorial youtube thumbnail
Just Enough webpack 5 tutorial youtube thumbnail

Notes summary

Core Concepts

Webpack configs

Webpack sample configs

 1const HtmlWebpackPlugin = require("html-webpack-plugin");
 2const webpack = require("webpack");
 3
 4module.exports = (env) => ({
 5  mode: env.mode,
 6  entry: "src/index.js",
 7  module: {
 8    rules: [
 9      {
10        test: /\.css$/,
11        use: [{ loader: "css-loader" }],
12      },
13    ],
14  },
15  output: {
16    filename: "dist/bundle.js",
17  },
18  plugins: [new HtmlWebpackPlugin(), new webpack.ProgressPlugin()],
19});

DevTools

The config devtools can be used to define the output of source maps to be used with DevTools

devtools: "source-maps" to export source maps

Webpack plugins and loaders

The following are some Webpack plugins and loaders:

Asset Modules

It’s a type of Webpack loaders included within it. There are 4 types of them:

In Webpack 4, these were achieved by loaders

Asset Module works with both import and new URL()

Webpack 5 Asset Modules youtube thumbnail
Webpack 5 Asset Modules youtube thumbnail

Code Splitting to improve web performance

Plugins System