Skip to main content

Webpack โ†” legacy production industry standard to Bundle Web App - slow clunky reliable ๐Ÿฑโ€๐Ÿ‰, deep config

Source: webpack.js.org/

webpack.config.jsโ€‹

Manifest to config Webpack behavior

image

Webpack flow

!limit

add Plugins to modify Webpack default behaviour

NpmInstallWebpackPluginโ€‹

!auto-fixes missing dependencies by installing modules from NPM

Example Webpack snippet for commonJS module

var webpack_modules = {
"./src/message.js": (module) => {
module.exports = "Hello World";
},
};

function webpack_require(moduleId) {
var moduleFn = webpack_modules[moduleId];
var module = { exports: {} };
moduleFn(module);
return module.exports;
}

const message = webpack_require("./src/message.js");
console.log(message);

Useful Webpack Hacks

TerserPluginโ€‹

Escape Hatch to patch Webpack into 21st century via Plugin

Webpack Plugin

Referencesโ€‹

  1. webpack.config.js โ†” Manifest to config Webpack behavior

  2. Vite โ†” Dev tool to scaffold & build framework UI, next-gen ESBuild Bundler 100X Webpack perf, support native Module, native TS

  3. esbuild-loader โ†” add this to every CRA project to fix the painful ass speed build times of Webpack!

  4. TerserPlugin โ†” Escape Hatch to patch Webpack into 21st century via Plugin

  5. SWC โ†” Rust Compiler to power Turbopack || extend Webpack