【问题标题】:How do <% .. %> scriptlets work in webpack?<% .. %> scriptlet 如何在 webpack 中工作?
【发布时间】:2020-04-12 00:05:15
【问题描述】:

全面披露:我是 webpack 的新手,并试图找出一些似乎在幕后发生的“魔法”。

在这个页面https://github.com/jantimon/html-webpack-plugin有一些这样的示例代码:

<title><%= htmlWebpackPlugin.options.title %></title>

似乎某种模板引擎在构建时运行以替换这些变量的值。我还看到了&lt;% ... some js code %&gt; 的其他示例。

我只是想知道模板是如何工作的以及它记录在哪里。它是否以某种方式内置于 webpack 本身?它是一个显式加载器吗?它是 htmlWebpackPlugin 的一部分还是可以与任何加载器一起使用?我已经尝试寻找答案,但在谷歌中搜索&lt;%= 非常成功

【问题讨论】:

    标签: webpack html-webpack-plugin


    【解决方案1】:

    The documentation has options that you can use for the template file

    查看所有可用选项

    来自文档:

    htmlWebpackPlugin:此插件特有的数据

    webpack:webpack stats 对象

    webpackConfig:用于编译的 webpack 配置。

    编译:webpack compilation 对象

    htmlWebpackPlugin 又有两个选项filesoptions。如果您想发送任何用户定义的值,请使用htmlWebpackPlugin.options

    【讨论】:

      猜你喜欢
      • 2023-01-03
      • 2014-06-05
      • 2020-07-14
      • 1970-01-01
      • 2018-03-24
      • 1970-01-01
      • 1970-01-01
      • 2018-12-01
      • 1970-01-01
      相关资源
      最近更新 更多