EJSテンプレートを実行せずにbundle.jsを動的に挿入しようとしていますが、以下のエラーが表示されます。 EJSテンプレートを実行せずにJSだけを挿入する方法はありますか?html-webpack-plugin - EJSテンプレートを実行しないでwebpack bundle.jsを挿入する方法
ERROR in Template execution failed: ReferenceError: description is not defined
ERROR in ReferenceError: description is not defined
私は実際にノードを使用してテンプレートをレンダリングしていると私はちょうどバンドルファイルを動的にtemplate.ejs
res.status(200).render('template',
{
description: description,
title:title
});
のWebPACKの設定に挿入されるようにしたい:
output: {
path: path.join(__dirname, 'dist'),
filename: "output.[hash].bundle.js",
publicPath: '/'
},
new HtmlWebpackPlugin({
inject: 'body',
template: 'views/template.ejs'
}),
テンプレート。 ejs
<!DOCTYPE html>
<html lang="en" class="ddhub-site">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="format-detection" content="telephone=no">
<meta description=<%=description%>/>
<title> <%= title %> </title>
</head>
<body></body>
</html>