Create a folder for webpack with CMD
mkdir webpack-demo && cd webpack-demo
Create package.json
npm init -y
Install webpack and webpack-cli
npm install webpack webpack-cli --save-dev
[vc_single_image image=”957″ img_size=”full”]
Create index.html
and src/index.js
[vc_single_image image=”959″ img_size=”full”]
index.html
<!doctype html> <html> <head> <title>Getting Started</title> <scriptsrc="https://unpkg.com/lodash@4.16.6"></script> </head> <body> <scriptsrc="./src/index.js"></script> </body> </html>
index.js
function component() { let element = document.createElement('div'); // Lodash, currently included via a script, is required for this line to work element.innerHTML = _.join(['Hello', 'webpack'], ' '); return element; } document.body.appendChild(component());
remove index.js entry from package.json and add private: true.
[vc_single_image image=”962″ img_size=”full”]