-
-
Couldn't load subscription status.
- Fork 1.3k
Description
Current behaviour 💣
I am trying to use the templateParameters to pass some variables into my template and it does not work.
I have followed the examples shown:
- Here: https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates
- And here: https://github.com/jantimon/html-webpack-plugin/tree/main/examples/template-parameters
Expected behaviour ☀️
I would like my <%= title %> to be replaced with the actual value of my templateParameters.title value, i.e. value located inside locales/de-DE.json or locales/en-GB.json.
I've also tried to modify the <%= title %> to <%= htmlWebpackPlugin.options.templateParameters.title %>.
Reproduction Example 👾
I have created a small repository to reproduce this issue here: https://github.com/einazare/html-webpack-plugin-18n-generator
You will need to:
- Install the dependencies with
npm install - Build the application with
npm run build - Open
dist/index.html - You will see
<%= title %>was not replaced bySome title written in English (Great Britain)
Environment 🖥
All the versions from my package.json file here:
"dependencies": {
"copy-webpack-plugin": "11.0.0",
"html-webpack-plugin": "5.5.0",
"webpack": "5.88.2",
"webpack-cli": "4.9.2",
"webpack-dev-server": "4.8.1"
},
"devDependencies": {
"css-loader": "6.7.1",
"html-loader": "4.2.0",
"style-loader": "3.3.1"
}
Also, the output of the above commands here:
node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
Node.js v18.16.0
darwin 22.6.0
npm --version
9.5.1
npm ls webpack
[email protected] /Users/einazare/Desktop/html-webpack-plugin-18n-generator
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ @webpack-cli/[email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
└─┬ [email protected]
└─┬ [email protected]
└── [email protected] deduped
npm ls html-webpack-plugin
[email protected] /Users/einazare/Desktop/html-webpack-plugin-18n-generator
└── [email protected]
Thank you 🙏