
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
html-require-loader
Advanced tools
Webpack loader for including requiring other HTML files with a <require> tag.
Webpack loader for including requiring other HTML files with a tag.
Allows for including HTML files like:
<body>
<h1 id="foo"></h1>
<h2 id="bar"></h2>
<require path="baz.html">
<require path="templates/qux.html">
</body>
npm install --save html-require-loader
| Option | Description | Default |
|---|---|---|
| root | Root path to look for templates. | Same path as required HTML file. |
var path = require('path');
module.exports = {
// ...
module: {
rules: [
{
test: /\.html/,
exclude: /(node_modules)/,
use: [
{
loader: 'html-require-loader',
options: {
root: path.resolve(__dirname, 'src')
}
}
]
}
]
}
// ...
}
And your require...
require('./index.html');
And then requiring or including other HTML files.
<body>
<h1 id="foo"></h1>
<h2 id="bar"></h2>
<require path="baz.html"></require>
<require path="templates/qux.html"></require>
</body>
Will be transformed into something like:
<body>
<h1 id="foo"></h1>
<h2 id="bar"></h2>
<!-- <require path="/path/to/baz.html"> -->
<h3 id="baz"></h3>
<!-- </require> -->
<!-- <require path="/path/to/qux.html"> -->
<h4 id="qux"></h4>
<!-- </require> -->
</body>
The HTML comments (require markers) are left in to potentially assist with other loaders for sourcemaps and hot reloading.
FAQs
Webpack loader for including requiring other HTML files with a <require> tag.
We found that html-require-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.