【问题标题】:how to get the diffs from two/three files and combine them in node?如何从两个/三个文件中获取差异并将它们组合到节点中?
【发布时间】: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


【解决方案1】:

我用这个要点解决了这个问题: https://gist.github.com/agoldis/21782f3b9395f78d28dce23e3b6ddd56

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-05
    • 2021-02-19
    • 1970-01-01
    • 2017-09-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-31
    相关资源
    最近更新 更多