This repository has been archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
htmlWebpackPlugin.options not available #47
Comments
Greetings, would you mind to show config? |
No, not at all. Here's my config, I have omitted irrelevant part of the code const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const pages = require('./pages.json');
const webpackConfig = {
module: {
rules: [
{
test: /\.twig$/,
type: 'asset/source',
use: [
{
loader: 'twig-html-loader',
options: {
data: context => {
const data = path.join(__dirname, './data/data.json');
context.addDependency(data);
return context.fs.readJsonSync(data, { throws: false }) || {};
}
}
}
]
}
]
},
plugins: []
};
pages.map(page => {
const trans = require(`./translations/messages.${page.lang}.json`);
webpackConfig.plugins.push(
new HtmlWebpackPlugin({
locale: page.lang,
filename: page.filename,
template: page.template,
trans
})
);
});
module.exports = webpackConfig; And in my twig file: {% extends "./layouts/default.twig" %}
{% block content %}
<h1>{{ htmlWebpackPlugin.options.trans.title }}</h1>
<div>{{ htmlWebpackPlugin.options.locale }}</div>
{% endblock %} |
Hello, I'm facing the same issue with a close configuration. Any update ? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
I'm trying to use data from htmlWebpackPlugin options as describe in Writing Your Own Templates section.
I tried to access the object but it's empty:
<h1>{{ htmlWebpackPlugin.options.title }}</h1>
Probably related to #26
Really appreciate your help
The text was updated successfully, but these errors were encountered: