@gozenc/interpolate-html-plugin

中文文档
1.0.2发布于 2021/04/02MITCommonJS零依赖近 30 天下载 5930

InterpolateHtmlPlugin implemented for webpack v5.

原始使用文档
文档目录5 节
  1. Overview
  2. Installation
  3. Usage
  4. Development
  5. ToDo

InterpolateHtmlPlugin

Replaces your variable names in your HTML templates.

Inspired from react-dev-utils/interpolate-html-plugin.
Written in TypeScript with ♥

Overview

It works in combination with latest versions of HtmlWebpackPlugin and webpack. You can learn more about creating plugins like this here.

Installation

NPMYARN
npm i -D webpack html-webpack-pluginyarn add -D webpack html-webpack-plugin
npm i -D @gozenc/interpolate-html-pluginyarn add -D @gozenc/interpolate-html-plugin

Usage

const HtmlWebpackPlugin = require("html-webpack-plugin")
const InterpolateHtmlPlugin = require("@gozenc/interpolate-html-plugin")
// In the webpack.config file:
...
plugins: [
    new InterpolateHtmlPlugin(HtmlWebpackPlugin, {
        'PUBLIC_URL': "https://example.com",
        // Replaces %PUBLIC_URL% with https://example.com in index.html.
        VARIABLE: 1024,
        // Replaces %VARIABLE% with 1024 in index.html.
    }),
    ...

Development

I know build pipeline looks kinda strange, but I am making some Linux practice with node concurrently for performant build pipelines. I may insert some C calls into it too. I'll develop it further in the future, but of course I am open for discussions for it.

Also just open a ticket for feature requests of course, I'll be glad to resolve them.

ToDo

  • Add webpack@3 support.
  • Add webpack@4 support.
  • More testing suites for development.
  • Type definitions for hook.tap params.

版本与发布记录

@gozenc/interpolate-html-plugin 共发布 3 个版本,首次发布于 2021/04/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.2latest2021/04/025 年前
1.0.12021/04/025 年前
1.0.02021/04/015 年前

关于 @gozenc/interpolate-html-plugin 的常见问题

@gozenc/interpolate-html-plugin 是什么?

InterpolateHtmlPlugin implemented for webpack v5.

如何安装 @gozenc/interpolate-html-plugin?

在项目目录运行 npm install @gozenc/interpolate-html-plugin,或使用 pnpm add / yarn add / bun add。

@gozenc/interpolate-html-plugin 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/gozenc__interpolate-html-plugin 是否存在。

@gozenc/interpolate-html-plugin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@gozenc/interpolate-html-plugin 可以商用吗?

@gozenc/interpolate-html-plugin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gozenc/interpolate-html-plugin 的下载量有多少?

根据 npm 官方下载统计,@gozenc/interpolate-html-plugin 在 2026/10/17 – 2026/11/15 这 30 天内被下载 5,930 次,日均约 198 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gozenc/interpolate-html-plugin 还在维护吗?

最新版本 1.0.2 发布于 2021/04/02(5 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/04/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。