Open StudioMaX opened 3 years ago
@StudioMaX
You can try template-ejs-loader
, it is a new loader which supports webpack 5
.
And you can also use it with html-loader
and htmlWebpackPlugin
.
I am now using it in my project, it actually works fine !
This loader hasn't been updated since last year and doesn't seem to support webpack 5.
For example, I could not find a solution for my problem of using
ejs-loader
andhtml-loader
at the same time. My current config with webpack 4 is something like:First, I process the ejs files through
html-loader
so that the webpack knows about static files (img src="/something.jpg"
, etc.). Then I pass output toextract-loader
, which extracts the module back to html/ejs strings. Then the processed .ejs passed intoejs-loader
.html-loader
>= 2.0 exports HTML as modules, addednew URL
syntax and usesparse5
for parsing ejs files. Next,extract-loader
is not supported since May 2020 and is therefore not compatible with webpack 5.html-loader
has an idea to add an option for similar functionality, this will partially solve the problem ofextract-loader
. But even after that, it will not be possible to usehtml-loader
anymore, since now it checks html tags more strictly and it will not allow to use ejs templates as before.A simple example of how it is used now (data comes from the backend):
Therefore, the question is how to similarly use webpack 5 with compiled ejs templates, while pre-processing the source templates to process them to the webpack (which is what the
html-loader
is doing now). Developers ofhtml-loader
says that other loaders likeejs-loader
should do this, andhtml-loader
loader will only support correct html tags.