简体   繁体   中英

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.)

EDIT: The above paragraph demonstrates that I missed an important point in the page cited. I couldn't find how to use strikeout text; I used italics. See Quentin's answer.

Thanks in advance ...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM