summaryrefslogtreecommitdiff
path: root/webpack.i18n.js
diff options
context:
space:
mode:
Diffstat (limited to 'webpack.i18n.js')
-rw-r--r--webpack.i18n.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/webpack.i18n.js b/webpack.i18n.js
new file mode 100644
index 0000000..bc9ee39
--- /dev/null
+++ b/webpack.i18n.js
@@ -0,0 +1,27 @@
+const path = require("path");
+const glob = require("glob");
+const I18nPlugin = require("i18n-webpack-plugin");
+
+const PATHS = {
+ build: path.join(__dirname, "i18n-build"),
+ i18nDemo: path.join(__dirname, "src", "i18n.js"),
+};
+
+const TRANSLATIONS = [{ language: "en" }].concat(
+ glob.sync("./languages/*.json").map(file => ({
+ language: path.basename(file, path.extname(file)),
+ translation: require(file),
+ }))
+);
+
+module.exports = TRANSLATIONS.map(({ language, translation }) => ({
+ entry: {
+ index: PATHS.i18nDemo,
+ },
+ output: {
+ path: PATHS.build,
+ filename: `[name].${language}.js`,
+ },
+ plugins: [new I18nPlugin(translation)],
+}));
+