Reputation: 17327
I'm trying to use webpack to recompose an HTML page using ejs. With the config below I'm getting the error.
Module build failed: SyntaxError: Unexpected token .
webpack.config.js
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
context: __dirname + "/src",
entry: ['./pages/index.ejx'],
output: {
path: __dirname + "/dist",
filename: "[name].bundle.js",
chunkFilename: "[id].bundle.js"
},
plugins: [
new HtmlWebpackPlugin({ template: 'pages/index.ejs'})
]
}
index.ejs
<!DOCTYPE html>
<html>
<% include ..partials/head %>
<% include ..partials/body %>
</html>
Upvotes: 2
Views: 3986
Reputation: 17327
This config seems to work so far:
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
context: __dirname + "/src",
entry: ['./index.ejs'],
output: {
path: __dirname + "/dist",
filename: "[name].bundle.js",
chunkFilename: "[id].bundle.js"
},
module: {
rules: [
{ test: /\.ejs$/, loader: "ejs-render-loader" }
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.ejs'
})
]
}
Upvotes: 2