简体   繁体   English

如何证明使用Webpack捆绑包?

[英]How can I demonstrate use of a webpack bundle?

Background: I have a web page. 背景:我有一个网页。 I'm trying to use webpack. 我正在尝试使用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. 我更改了package.json,构建了webpack.config.js,发出了CLI webpack编译命令,并在指定的目录中获得了名称正确的新文件(* .bundle.js)。 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. 当我将浏览器指向它时,期望得到我的网页,但是浏览器显示了JavaScript webpack编写的内容。

Following the instructions at http://webpack.github.io/docs/tutorials/getting-started/ , I would point the browser to the original files. 按照http://webpack.github.io/docs/tutorials/getting-started/上的说明,我将浏览器指向原始文件。 Sure! 当然! They display the web site, but does webpack? 他们显示网站,但是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. 网页将所有JavaScript文件捆绑为一个JavaScript文件,并替换了require调用。

It is still a JavaScript file. 它仍然是一个JavaScript文件。

You don't point the browser at a JavaScript file. 您无需将浏览器指向JavaScript文件。 You point the browser at an HTML document with a <script src="/path/to/the/packed.bundle.js"></script> element in it. 您将浏览器指向带有<script src="/path/to/the/packed.bundle.js"></script>元素的HTML文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在没有webpack开发服务器的情况下仅将webpack用于捆绑? - How can I use webpack just for bundle without webpack dev server? 在webpack中,我只能在一个条目包中使用commonchunks插件吗 - In webpack can I only use commonchunks plugin in one entry bundle 如何找出页面上正在使用的 javascript 对象? (挖掘 webpack 捆绑包) - how can I find out what javascript objects are in use on a page? (digging through a webpack bundle) 如何在Webpack中有条件地使用捆绑软件 - How to conditionally use a bundle in webpack 我如何让webpack捆绑我的CSS文件? - How can I have webpack bundle my css file? 如何使用 webpack 和 file-loader 在两个捆绑 (scss) 文件中使用一个图像? 最后一个返回 undefined - How can I use one image in two bundle (scss) files with webpack and file-loader? The last one of them returns undefined 如何构建从另一个入口点包导入模块的webpack包? - How can I build a webpack bundle that imports a module from another entry point bundle? 如何配置 Webpack 5 捆绑使用全球 jQuery? - How to configure Webpack 5 bundle to use global jQuery? 如何将js库与webpack捆绑在浏览器中使用? - How to bundle js library for use in browser with webpack? 如何将 webpack 与 express 一起使用? - How can I use webpack with express?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM