0.0.5 • Published 6 years ago
ejs-templates-loader v0.0.5
ejs-templates-loader
EJS loader module for webpack
Installation
npm install --save ejs-templates-loaderUsage
webpack.config.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
module: {
rules: [
{
test: /\.ejs$/,
use: {
loader: 'ejs-templates-loader',
options: {
delimiter: '$'
}
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'title',
filename: 'index.html',
template: './index.ejs'
})
]index.ejs
<!DOCTYPE html>
<html>
<head>
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<$- include('./_header', {foo: 'foo'}) $>
<img src="<%= require('./img/image.jpg') %>">
<$- include _footer $>
</body>
</html>Options
delimiter— Character to use with angle brackets for open/close (default:"%")beautify— Enable/Disable beautification (default:false)beautifyOptionsSee js-beautify#options (default:{})