ThisNameWasTaken / ejs-plain-loader

MIT License
3 stars 1 forks source link

"ReferenceError: htmlWebpackPlugin is not defined" in ejs template when using htmlWebpackPlugin.options.title #6

Open snoleo opened 4 years ago

snoleo commented 4 years ago

I suggest to support htmlWebpackPlugin.options in the ejs templates: -- webpack.conf.js --

module: {
  rules: [
    {
      test: /\.ejs$/i,
      use: [
        { loader: 'html-loader', options: { minimize: false, esModule: false } },
        { loader: 'ejs-plain-loader' }
      ]
    }
  ]
},
plugins: [
  new HtmlWebpackPlugin({
    chunks: ['outputA'],
    template: './template.ejs',
    filename: './output.html',
    title: 'Output Page Title',
    meta: { 'keywords': 'aaa,bbb', 'description': 'webpage descriptions' }
  })
]

-- template.ejs --

<title><%= htmlWebpackPlugin.options.title %></title>

should generate html:

<title>Output Page Title</title>
<meta name="keywords" content="aaa,bbb">
<meta name="description" content="webpage descriptions">
shaozhuang commented 4 years ago

I encountered the same problem☹️

snoleo commented 4 years ago

I encountered the same problem☹️

You can try : https://github.com/snoleo/ejs-easy-loader