Registry / web-framework / ejs-webpack-loader

ejs-webpack-loader

JSON →
library2.2.2jsnpmunverified

EJS template loader for webpack 4.x that compiles .ejs files into JavaScript template functions using the ejs library. Version 2.2.2 is the latest stable release, with no recent updates. It supports options like beautify, compileDebug, and htmlmin. Unlike ejs-loader or ejs-compiled-loader, this package is specifically designed for webpack 4 and avoids frontend dependencies. Useful for server-side rendering or generating HTML files with webpack.

npm install ejs-webpack-loader
INSTALL
IMPORT
SIG · EJS-WEBPACK-LOADER
E
ejs-webpack-loader
web-frameworkjavascriptv2.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

ejs-webpack-loader
import 'ejs-webpack-loader' // no import, used in webpack config
const loader = require('ejs-webpack-loader')
This package is a webpack loader, not a JavaScript module. It is used in webpack configuration under module.rules.
default export
rule.use = [{ loader: 'ejs-webpack-loader', options: { data: {...}, htmlmin: true } }]
rule.loader = 'ejs-webpack-loader?data=...'
Pass options using the options object, not query string, to avoid deprecation warnings in webpack 4.
template function
import template from '!!ejs-webpack-loader!./file.ejs'; // returns function
import template from './file.ejs' // without loader prefix
Use inline loader syntax (!!) with HtmlWebpackPlugin or for direct require.

Webpack configuration using ejs-webpack-loader to compile .ejs templates with data and HTML minification.

// webpack.config.js const path = require('path'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist') }, module: { rules: [{ test: /\.ejs$/, use: [{ loader: 'ejs-webpack-loader', options: { data: { title: 'Hello', someVar: 'World' }, htmlmin: true } }] }] } };
Debug
Known issues
gotchaEJS data must be passed via the 'data' option, not directly in the template. The template cannot access webpack variables like __dirname.
fix
Pass all variables under the 'data' property in the loader options.
affects: >=0.0.0
gotchaThe loader returns a function, not a string. To get rendered HTML, you must call the function with data (or use separate extractors like file-loader or HtmlWebpackPlugin).
fix
Use extract-loader or HtmlWebpackPlugin to output HTML, or call the returned function in your code.
affects: >=0.0.0
deprecatedWebpack 4 loader query string options (e.g., 'ejs-webpack-loader?htmlmin=true') are deprecated in favor of the 'options' object.
fix
Use the 'options' property in the rule as shown in the quickstart.
affects: <2.0.0
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
Missing or misconfigured rule for .ejs files in webpack config.
fix
Add a rule with ejs-webpack-loader as shown in the quickstart.
Error: Could not find loader 'ejs-webpack-loader'
Package not installed or not in node_modules.
fix
Run 'npm install ejs-webpack-loader --save-dev'
TypeError: template is not a function
Using the exported function as a string without calling it.
fix
Call the imported template function with data: template({ title: '...' })
Upgrade
Version history
2.2.2latest on npm
Audit
Dependencies
ejsrequiredCore template engine required at runtime to compile .ejs files.
html-minifieroptionalRequired only if the htmlmin option is set to true to minify HTML output.
Agent activity
6 hits · last 30 days
node
6
Resources
ejs-webpack-loader — npm install ejs-webpack-loader · libregistry