handlebars-webpack-plugin
handlebars-webpack-plugin copied to clipboard
HandlebarsPlugin + i18next + watchmode
I am looking for a solution to use HandlebarsPlugin with i18next and the watch mode of webpack.
Currently I am initializing i18next at the top of my webpack configuration. I also use HandlebarsI18n helpers to manage translations.
i18next.init({
lng: 'en',
debug: true,
resources: {
en: {
translation : require('../locales/en/translation.json')
},
fr: {
translation : require('../locales/fr/translation.json')
}
}
});
It works fine if I'm not in watch mode
I currently have two problems.
- When I modify an hbs file, the watch effectively relaunches the build. However, the translations are not reloaded. I guess HandlebarsPlugin do not reinit its configuration.
- When I modify a json translation file, the watch does not restart the build.
I tried to restart the initialization of i18next in the different hooks offered by HandlebarsPlugin (onBeforeSetup, onBeforeAddPartials, onBeforeCompile, ...) But it doesn't work.
Do you have any idea how to reload the translations with webpack's watch mode?
I also tried the plugins: prebuild-webpack-plugin and before-build-webpack without success
Thank's for your help