BaldEagle BaldEagle - 3 months ago 14
Javascript Question

How can I demonstrate use of a webpack bundle?

Background: I have a web page. I'm trying to use webpack. I altered my package.json, built a webpack.config.js, issued a CLI webpack compile command, and got new file with the right name (*.bundle.js) in the directory I specified. That file is impressively smaller than the group of files it should replace.

How do I use that file?

When I point a browser to it, expect to get my web page, but the browser shows me the JavaScript webpack wrote.

Following the instructions at http://webpack.github.io/docs/tutorials/getting-started/, I would point the browser to the original files. Sure! They display the web site, but does webpack? (I presume it does, but I don't to how to do it.)

Thanks in advance ...

Answer

Webpage bundles all the JavaScript files up into a single JavaScript file and replaces the require calls.

It is still a JavaScript file.

You don't point the browser at a JavaScript file. You point the browser at an HTML document with a <script src="/path/to/the/packed.bundle.js"></script> element in it.