dc7290 / template-ejs-loader

ejs-loader with webpack5 support. Chain it to html-loader and use it with html-webpack-plugin.
MIT License
24 stars 3 forks source link

Fix htmlWebpackPluginTemplateCustomizer option type problem #20

Closed mizok closed 2 years ago

mizok commented 2 years ago

Description

I found that the problem was caused by query string.

When we parsed the full loader option object to query string, it actually parsed every value to string, which means there will be no Boolean type value.

check this: https://stackoverflow.com/questions/6461668/boolean-in-a-uri-query

So here my solution is parsing options to JSON using JSON.stringify, instead of parsing to query string( JSON is also an acceptable type here for webpack loader inline).

check this: https://webpack.js.org/concepts/loaders/#inline

But unfortunately, both of these two way do NOT support option value in which type is function, which means the html-loader option : preprocessor is not supported here (I not only mentioned this in README.md, but also made a colorful console.log inside index.ts in case someone doesn't read the doc)

Any suggestion will be appreciated, I am wondering if there will be a better way to fix this issue.

Fixes #19 (issue)

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Checklist:

dc7290 commented 2 years ago

@mizok

Thank you very much.

This usage was completely unexpected and I was not able to support it. The reason why we didn't notice it is because there is no description to test the use with html-webpack-plugin or html-loader at this stage. We will review the test format and change it to be more in line with actual use cases in the future.

However, as we have limited time to work on this issue, for now it will suffice to add the README description and error messages as you have done.

Thank you for everything.