1.0.2 • Published 6 years ago

ejs-file-loader v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Webpack EJS Template Loader

Build Status

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

:cloud: Installation

npm i -D ejs-file-loader

:clipboard: Example

JavaScript

var template = require("ejs-file-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

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

:memo: 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

htmlminify

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

See all options reference

:scroll: License

MIT