npm i -g webpack this will install it globally on your system, use (sudo) if there is a problems.
You can use the npm scripts for small project to compile wabpack:
"scripts": {
"build": "webpack src/main.js dist/bundle.js",
"watch": "npm run build -- --watch"
}
Then in the terminal run: npm run build [for the first command]
or: npm run watch [for the second command, to watch for future updates]
In the project root create file: webpack.config.js webpack will look here for the comand webpack.
Check docs how to's for other locations.
Simplest config file, that executes with webpack terminal command:
var webpack = require('webpack');
var path = require('path'); // needed for absolute path
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'), // absolute path
filename: 'bundle.js'
}
};
then the npm scripts in package.json can be modified to math that file:
"build": "webpack",