Install NodeJS


Edit the package.json and add


  "scripts": {
    "build": "webpack --mode development",
    "watch": "webpack --mode development --watch"
  }

Then running

``npm run build``


examples/demo-app/dist/index.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Getting Started</title>
  </head>
  <body>
    <script src="./main.js"></script>
  </body>
</html>

examples/demo-app/src/index.js
import add from './mymath';

console.log("hello world");
console.log(add(2, 8));

examples/demo-app/src/mymath.js
export default function add(x, y) {
    return x + y;
}

examples/demo-app/package.json
{
  "name": "demo-app",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack --mode development",
    "watch": "webpack --mode development --watch"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^5.86.0",
    "webpack-cli": "^5.1.4"
  }
}