Support for latest version of html-webpack-plugin
I use template-ejs-loader on all my projects but on the latest upgrade of HTMLWebpackPlugin and HTML loader packages I can't use it since there is an error.
The main problem is on the 88-th line of code where we check whether plugin.options.template === this.resource in this scenario we never pass the test because this.resource is something like: D:\[path_to_file]\index.ejs and plugin.options.template is D:\[path_to_project]\node_modules\.pnpm\[email protected][email protected]\node_modules\html-webpack-plugin\lib\loader.js!D:\[path_to_file]\index.ejs
I found out that this will solve the problem:
const currentHtmlWebpackPlugin = this._compiler?.options.plugins.filter((plugin) => typeof plugin === 'object' &&
plugin.options &&
plugin.options.template &&
(plugin.options.template === this.resource || plugin.options.template.split('!')[1]))[0];
Can you consider in the near future and fix it so that it works on the latest versions of the mentioned plugins.
@PredragNa
you can try to use the modern html-bundler-webpack-plugin. This plugin supports EJS and many others templating engines out of the box.
The plugin replaces the functionality of the plugins and loaders:
- html-webpack-plugin
- template-ejs-loader
- html-loader
- mini-css-extract-plugin
- many other plugins and loaders
P.S. the template-ejs-loader has not been updated for the last 2 years. It's time to switch to an actual HTML Bundler Plugin.
@webdiscus Thank you very much. I'll take a look.