Bundling modules in Webpack

To start using Webpack, let's first write some JavaScript code. Open up your memes.js file and general.js file. Write the following code in both files, which simply prints the respective filenames in the console:

// inside memes.js fileconsole.log('Memes JS file');// inside general.js fileconsole.log('General JS File');

Usually, while building multiple page web applications that have a large number of HTML files, it's common to have a single JavaScript file that has code that requires being run on all the HTML files. We are going to use the general.js file for this purpose. Even though our Meme Creator has a single HTML file, we'll use the general.js file to include some common code and include the code for Meme ...

Get JavaScript by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.