EJS loader for webpack. Uses ejs function to compile templates.
This is the fork of the now abandoned bazilio91/ejs-compiled-loader with updated dependencies, fixed vulnerabilities, and updated code base.
The main differences are:
- uses
[email protected]
instead of 2.x becauseejs
up to 3.1.9 has multiple vulnerabilities (CVE-2022-29078, CVE-2024-33883); - uses
html-minifier-terser
instead of the abandonedhtml-minifier
(which is affected by a ReDoS vulnerability). Some options ofhtml-minifier-terser
differs from those ofhtml-minifier
; - does not suppoprt Webpack 4.x.
npm install -D @myrotvorets/ejs-compiled-loader
const template = require("ejs-compiled-loader!./file.ejs");
// => returns the template function compiled with ejs templating engine.
// And then use it somewhere in your code
template(data) // Pass object with data
The following options are supported:
beautify
: enable or disable terser beautify of the template AST;compileDebug
: see the EJScompileDebug
option;htmlmin
: whether to enable HTML minification;htmlminOptions
: options passed tohtml-minifier-terser
;minimize
: whether to minimize the resulting JS code with Terser;terserOptions
: options passed toterser
;- options supported by EJS.