Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/iyonaga/ejs-templates-loader

EJS loader module for webpack
https://github.com/iyonaga/ejs-templates-loader

ejs ejs-loader webpack webpack-loader

Last synced: 2 months ago
JSON representation

EJS loader module for webpack

Awesome Lists containing this project

README

        

# ejs-templates-loader
EJS loader module for webpack

## Installation

```shell
npm install --save ejs-templates-loader
```

## Usage

### webpack.config.js

```js
module: {
rules: [
{
test: /\.ejs$/,
use: {
loader: 'ejs-templates-loader',
options: {}
}
}
]
},

plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './index.ejs'
})
]
```

### Advanced configuration example

#### webpack.config.js
```js
module: {
rules: [
{
test: /\.ejs$/,
use: {
loader: 'ejs-templates-loader',
options: {
delimiter: '$'
}
}
}
]
},

plugins: [
new HtmlWebpackPlugin({
title: 'title',
filename: 'index.html',
template: './index.ejs'
})
]
```

#### index.ejs
```html
<!DOCTYPE html>


<%= htmlWebpackPlugin.options.title %>


<$- include('./_header', {foo: 'foo'}) $>

<$- include _footer $>

```

## Options
- `delimiter` — Character to use with angle brackets for open/close (default: `"%"`)

- `beautify` — Enable/Disable beautification (default: `false`)

- `beautifyOptions` See [js-beautify#options](https://github.com/beautify-web/js-beautify#options) (default: `{}`)