【发布时间】:2021-02-15 19:40:51
【问题描述】:
我一直在玩 webpack,我能够使用钩子直接从 HtmlWebpackPlugin 输出和转换 es5 buid 以在标签中包含 nomodule。与 es6 构建相同,但输入 type="module"。
现在的问题是我有两个基于相同模板文件的 html 文件。 这是一个示例,请不要介意缺少的标签来说明会发生什么。 模板.html:
<body class="container">
</body>
es5.main.html
<link href="main.ef35cd992b2eaf651405.css" rel="stylesheet">
<body class="container">
</body>
<script src="runtime.1ee16c2201d417984a0f.bundle.es5.js" nomodule></script>
es6.main.html
<link href="main.ef35cd992b2eaf651405.css" rel="stylesheet">
<body class="container">
</body>
<script src="runtime.f00dbe9b3232d30ba93f.bundle.es6.js" type="module"></script>
我想知道在构建之后我可以运行一个节点脚本来从 dist 文件夹中获取差异并将其合并到一个文件中。有什么想法可以做到吗?
【问题讨论】:
-
您使用的是什么操作系统?在 Mac 和 Linux 上,这很容易。在 Windows 上,这在 gitbash 或 MinGW 或在 WSL 上运行的某些 Linux 发行版中很容易
-
我在 Windows 上,但我确实安装了 bash。我确实需要它可以从 cli 运行,以便我可以与 webpack 集成。
标签: javascript html node.js webpack