• Installation
  • Compiling JavaScript
  • Creating a JavaScript module
  • FURTHER READING

    Installation

    Installation is via npm:

    1. npm install webpack -g

    Compiling JavaScript

    Give Webpack an entry point and an output file:

    1. webpack ./app.js app.bundle.js

    Creating a JavaScript module

    We can define modules in JavaScript using the CommonJS syntax, as for Node:

    cats.js

    1. var cats = ['dave', 'henry', 'martha'];
    2. module.exports = cats;

    app.js

    1. cats = require('./cats.js');
    2. console.log(cats);

    FURTHER READING

    Recommended reading: Webpack your bags by Maxime Fabre - a very good introduction on how to setup a real-world project using Webpack.

    • see [[CLI]] for the command line interface.
    • see [[node.js API]] for the node.js interface.
    • see [[Configuration]] for the configuration options.