Answer the question
In order to leave comments, you need to log in
How to create multiple html pages from ejs templates in webpack?
I understand webpack and can't figure out which plugin(s) to use to generate html statics from ejs templates. I have in a project:
ejs/
L shared/
L header.ejs
L footer.ejs
L index.ejs
L 404.ejs
L contact.ejs
static/
L index.html
L 404.html
L contact.html
import './ejs/index.ejs';
import './ejs/404.ejs';
import './ejs/contact.ejs';
Answer the question
In order to leave comments, you need to log in
Something like that, mb something needs to be added / corrected.
HtmlWebpackPlugin
import './ejs/index.ejs';
import './ejs/404.ejs';
import './ejs/contact.ejs';
const htmls = ["index", "404", "contact"].map(template => {
new HtmlWebpackPlugin({
template: `./static/${template}.html`,
filename: `${template}.html`,
chunks: [`${template}`]
})
};
module.exports = {
entry: {
index: './ejs/index.ejs',
404: './ejs/404.ejs',
contact: '. / ejs / contact.ejs'.
},
plugins: [htmls]
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question