Specifying an Entry Point
$ npm run build:dev
Error: need an entry point
// **** webpack.config.babel.js
// 2. ++++ add the path module
// on node 6 you can use the destructuring ES6 syntax
const {resolve} = require('path')
module.exports = env => {
return {
// 1. ++++ need a context which is
// an absolute path
context: resolve('src'),
// 3. ++++ and the entry point
entry: './bootstrap.js',
output: {
filename: 'bundle.js',
},
}
}
Now you should get the output summary in your console and the output bundle.js file. bundle.js (Webpack output).
Notice, that the entry point file, bootstrap.js has no any explicit dependency declarations, just the IIFE and some handlers.
Webpack comes with its own runtime and it will add its own require statements and resolve the modules at runtime. So it adds a lot of extra code at the beginning of the file.
Webpack already wraps our file in an IFEE so we don't need that in our source code.
Now, in our html file we can replace bootstrap.js with our bundle.js file. Everything works.