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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.