Webpack | Guides

A stunningly stupid "build tool". Rigid as Rigamortis, and brittle as cheap china; forbidden filenames; forbidden directory names; the list of forbiddens is damn near infinite. The resulting bundle.js is a horror show. In a word, it's npm.

npm init -y
npm i webpack --save-dev
npm i webpack-cli --save-dev

tl;dr

The resulting build (bundle.js), to import a one-line function, is 100 lines of horrific code. Somehow, they managed to do this even to the ES6 Module system; transmuting its one-liner import { name} ... statement into their big garbled mess. The process is heavily imperative. Its own core config files, package.json and webpack.config.js, mutate with build phases, each of each phase requiring manual edits, and all by design.

Mod @ webpack.config.js

Mod @ index.js

import { cube } from './math.js'

Mod @ math.js

Mod @ package.json

{
  "name": "webpack-x",
  "sideEffects": [
      "protect-this-polyfill.js",
      "*.css"
      ]
//...
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack"
},
//...

Build

npm run build

@ bundle.js

@ bundle.devel.js (renamed/saved)

Tree Shaking