@myrotvorets/ejs-compiled-loader
v4.0.0
Published
EJS webpack loader (without frontend dependencies)
Downloads
57
Maintainers
Readme
ejs-compiled-loader for webpack
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.
Installation
npm install -D @myrotvorets/ejs-compiled-loader
Usage
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
Options
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.
License
MIT (http://www.opensource.org/licenses/mit-license.php)