Skip to content

keiches/ejs-template-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EJS Template to string loader for Webpack

EJS loader for webpack. Uses ejs function to compile templates.

To use EJS by mde use 2.x branch and 2.x.x versions.

*** Forked from ejs-file-loader ***

Installation

npm install --save-dev ejs-template-loader

Usage

var template = require("ejs-template-loader!./file.ejt");
// => returns the template function compiled with ejs templating engine.

// And then use it somewhere in your code
template(data) // Pass object with data

// Child Templates
// path is relative to where webpack is being run
<%- include templates/child -%>

Documentation

Documentation: Using loaders

Following options can be specified in query:

beautify — enable or disable uglify-js beautify of template ast

compileDebug — see ejs compileDebug option

htmlmin — see htmlminify section

Examples for html minify

const webpackConfigs = {
  module: {
    loaders: [
      {test: /\.ejs$/, loader: 'ejs-file-loader?htmlmin'} // enable here
    ]
  },
  'ejs-template-loader': {
    'htmlmin': true, // or enable here
    'htmlminOptions': {
      removeComments: true
    }
  }
};

See all options reference

License

MIT

About

EJS Template to string loader for Webpack v4

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published