⊗tlWpHtMScB 41 of 55 menu

Multiple Script Bundles in a Layout in Webpack

If we get several bundles as a result of the build, Webpack will include each of them. Let's check. Let's say we have the following settings:

export default { context: path.resolve( 'src'), entry: { test1: './test1.js', test2: './test2.js' }, output: { filename: '[name].build.js', path: path.resolve('dist'), }, plugins: [ new HtmlWebpackPlugin(), ], };

After assembly, both of our bundles will be connected to the layout file:

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Webpack App</title> <script defer src="test1.build.js"></script> <script defer src="test2.build.js"></script> </head> <body> </body> </html>

Make three entry points. Build. Examine the layout file and make sure all your bundles are included.

enru