Quick instructions for Webpack-ifying backend Node.js code:
npm install --save-dev webpack-node-externals webpack webpack-cli nodemon
- Ensure
main
is withinpackage.json
- Add
*.dist.js
to.gitignore
- Create included
webpack.config.js
- Run
npx webpack --watch
in combination withnpx nodemon MAIN.dist.js
To make things easier, additionally:
npm install --save-dev nodemon
- Add
node MAIN.js
as thestart
script. - Add
nodemon MAIN.dist.js
as thedev
script.