EJS loader module for webpack
npm install --save ejs-templates-loader
module: {
rules: [
{
test: /\.ejs$/,
use: {
loader: 'ejs-templates-loader',
options: {}
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './index.ejs'
})
]
module: {
rules: [
{
test: /\.ejs$/,
use: {
loader: 'ejs-templates-loader',
options: {
delimiter: '$'
}
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'title',
filename: 'index.html',
template: './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>
-
delimiter
— Character to use with angle brackets for open/close (default:"%"
) -
beautify
— Enable/Disable beautification (default:false
) -
beautifyOptions
See js-beautify#options (default:{}
)