Closed fireairforce closed 1 year ago
It seems that html-webpack-plugin
use lodash.escape
to deal the parameter string:
But i use EJS's <-% %>
synatax to avoid escape here.
Can you provide your configuration for html-webpack-plugin?
@alexander-akait I just use the example of html-webpack-plugin/examples/template-parameters
, the config as follows:
var path = require('path');
var HtmlWebpackPlugin = require('../..');
var webpackMajorVersion = require('webpack/package.json').version.split('.')[0];
module.exports = {
context: __dirname,
entry: './example.js',
output: {
path: path.join(__dirname, 'dist/webpack-' + webpackMajorVersion),
publicPath: '',
filename: 'bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
// If you pass a plain object, it will be merged with the default values
// (New in version 4)
templateParameters: {
'foo': 'bar',
baseUrl: 'https://baidu.com/test?b=1&a=1<2333',
},
// Or if you want full control, pass a function
// templateParameters: (compilation, assets, assetTags, options) => {
// return {
// compilation,
// webpackConfig: compilation.options,
// htmlWebpackPlugin: {
// tags: assetTags,
// files: assets,
// options
// },
// 'foo': 'bar'
// };
// },
template: 'index.ejs'
})
]
};
Sounds like a bug, feel free to send a fix
Sorry i found this might not be html-webpack-plugin
's bug, if i use <%= =>
here it will work fine.
Current behaviour 💣
Please take a look at reproduction example.
The
&
will be translated to&
.Expected behaviour ☀️
I just want to keep the origin
&
.Reproduction Example 👾
We can just use
html-webpack-plugin/examples/template-parameters
.Update
webpack.config.js
:And then use this parameter under template ejs file:
Then execute webpack to build the project, you will found the output of the html will get
testUrl
like:Environment 🖥
node: v16.17.0 html-webpack-plugin: latest webpack: v5