Registry / devops / gulp-require-html-inline

gulp-require-html-inline

JSON →
library1.0.4jsnpmunverified

A Gulp plugin that replaces JavaScript require() calls referencing HTML files with the inlined HTML content as template literals. Version 1.0.4 is stable but sees no active development; last updated in 2020. It uses html-minifier-terser (peer dependency >=5) to minify HTML before inlining. Differentiators: simple regex-based detection (no AST), supports .htm/.html, handles all quote types. Caveats: no semantic parsing, multiline HTML may break commented require()s, peer dependency must be installed separately.

npm install gulp-require-html-inline
INSTALL
IMPORT
SIG · GULP-REQUIRE-HTML-
G
gulp-require-html-inline
devopsjavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const htmlInline = require('gulp-require-html-inline');
import htmlInline from 'gulp-require-html-inline';
This package is CJS-only. ESM import will fail.
htmlInline
const htmlInline = require('gulp-require-html-inline');
const { htmlInline } = require('gulp-require-html-inline');
Default export is a function; no named export exists.
htmlInline
const htmlInline = require('gulp-require-html-inline');
const htmlInline = require('gulp-require-html-inline').default;
CommonJS default export is the function directly, not a .default property.

Shows basic Gulp task using htmlInline plugin to replace require('./test.html') with inlined HTML template literal.

const gulp = require('gulp'); const htmlInline = require('gulp-require-html-inline'); gulp.task('default', function() { return gulp.src('./file.js') .pipe(htmlInline()) .pipe(gulp.dest('result')); }); // Input file.js: // var a = require('./test.html'); // // test.html: // <div>Hello World</div> // // Output result/file.js: // var a = `<div>Hello World</div>`;
Debug
Known issues
deprecatedPackage not updated since 2020. May not work with latest Gulp 5+ or Node.js versions.
fix
Evaluate alternatives like webpack html-loader or rollup-plugin-string.
affects: >=1.0.4
gotchaRequire statements are detected via regex, not AST. Complex code with dynamic strings or nested requires may produce false positives/negatives.
fix
Ensure require calls follow exact pattern: require('path.html'). Avoid obfuscated or dynamically constructed require strings.
affects: >=0.0.1
gotchaMissing peer dependency html-minifier-terser (>=5) causes error at plugin runtime.
fix
Run: npm install --save-dev html-minifier-terser@5
affects: >=1.0.0
gotchaIf custom minifier options disable collapseWhitespace, multiline HTML may break commented-out require() statements.
fix
Keep collapseWhitespace: true or use html-minifier-terser defaults.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: htmlInline is not a function
Importing with ES6 import syntax instead of CommonJS require.
fix
Use const htmlInline = require('gulp-require-html-inline');
Error: Cannot find module 'html-minifier-terser'
Missing peer dependency html-minifier-terser.
fix
npm install --save-dev html-minifier-terser@5
The gulpfile.js is not loading the tasks - require() not replaced as expected
Plugin uses regex and may miss requires if they are not simple string literals.
fix
Ensure require calls are exactly like require('./file.html') with single/double/template quotes.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
html-minifier-terserrequiredPeer dependency; used to minify HTML files to single lines before inlining.
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-require-html-inline — npm install gulp-require-html-inline · libregistry