I am trying to configure webpack for my project. The project is large enough and is available in several languages. I want each of my entry points provided in each language as separate files. My language files are not just JSON, but JavaScript. Therefore, the i18n plugin does not meet my needs.
The solution is similar to the i18n plugin:
var languages = ['en', 'fr', 'de'];
module.exports = languages.map(function (lang) {
return {
name: lang,
}
})
Then, in some of my scripts, I want to require a localization file using an environment variable:
var lang = ...;
var l10n = require('./lang/' + lang);
But by default, webpack tries to keep this expression between parentheses, assuming that it will later be in the browser.
So, is there a way to tell webpack to immediately evaluate this?
Or maybe someone has a better solution to my problem?