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
muslnode 18–226 runs
build_error
glibcnode 18–226 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 } }]
}]
}
};
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.
fixAdd 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.
fixRun 'npm install ejs-webpack-loader --save-dev'
TypeError: template is not a function
Using the exported function as a string without calling it.
fixCall the imported template function with data: template({ title: '...' }) 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.