npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

webpack-html-include-loader

v0.1.5

Published

A easy way to include one html file in anohter html file~!

Downloads

2

Readme

README in English click here

简介

这是一个webpack loader, 可以方便地在一个html文件中包含另一个html文件。并且被包含的HTML变化时,会动态更新。

基础用法

如果你想在某个html文件中包含另一个html文件,如:header.html,你可以像下面这样写:

<%- include("./incs/header.html") %>

此外,你可以已在包含html文件的时候传入自定义参数,如下所示:

<%- include("./incs/header.html", {"title": "首页"}) %>

header.html中可以通过<%= title %>来注入变量。

需要注意的是,传入参数的时候,格式需要时JSON序列化的字符串,因为需要对其进行转义,如果格式不正确会报错。

这都是最基础的功能,webpack-html-include-loader还支持嵌套包含,即在包含的html中再次包含其他文件。这会大大提高我们使用的灵活度。

如果你害怕会出现过多的嵌套,还可以通过自定义选项options来限制最大嵌套层数,参见下一部分。

高级用法

简易条件表达式

除了常规的变量注入,在使用时,还可以使用简易的条件表达式,格式如下:<%= isIndex ? '这里是首页' : '这里是其他页面' %>"。会根据传入的变量isIndex值判断,替换为不同的文本。

自定义选项

maxIncludes 最大包含嵌套层数

默认值为5,如果有需要可以适当放大和减小。

includeStartTag 包含块起始标记

默认值为<%-,如果你更习惯使用其他标记,可以通过该参数进行调整。

includeEndTag 包含块结束标记

默认值为%>,如果你更习惯使用其他标记,可以通过该参数进行调整。

variableStartTag 变量起始标记

默认值为<%=,如果你更习惯使用其他标记,可以通过该参数进行调整。

variableEndTag 变量结束标记

默认值为%>,与包含块结束标记相同,如果你更习惯使用其他标记,可以通过该参数进行调整。