[英]How to bundle legacy js files with webpack?
Suppose I have two files假设我有两个文件
a.js: a.js:
alert("hello from a.js");
b.js js
alert("hello from b.js");
is there any way to bundle them with WebPack so that有没有办法将它们与 WebPack 捆绑在一起,以便
Webpack natively supports CommonJS ( require / import ) and AMD style, and since yours are not falling into those categories, I believe you should look at the shimming modules section Webpack 本身支持 CommonJS ( require / import ) 和 AMD 风格,并且由于您的不属于这些类别,我相信您应该查看 shimming modules 部分
https://github.com/webpack/docs/wiki/shimming-modules https://github.com/webpack/docs/wiki/shimming-modules
This is from their header这是他们的标题
In some cases webpack cannot parse some file, because it has a unsupported module format or isn't even in a module format.
在某些情况下 webpack 无法解析某些文件,因为它具有不受支持的模块格式或什至不是模块格式。 Therefore you have many options to convert the file into a module.
因此,您有许多选项可以将文件转换为模块。
对于任何其他人来看,新的(webpack 4+)链接到关于垫片的文档在这里: https ://webpack.js.org/guides/shimming/
就我个人而言,这个 webpack 插件是最有帮助和头疼的: https ://www.npmjs.com/package/webpack-merge-and-include-globally
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.