forked from cschleiden/imperaplus-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
81 lines (67 loc) · 1.99 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"use strict";
const path = require("path");
const webpack = require("webpack");
const loaders = require("./webpack/loaders");
const plugins = require("./webpack/plugins");
// Prod plugins
const HtmlWebpackPlugin = require('html-webpack-plugin');
const I18nPlugin = require("i18n-webpack-plugin");
const languages = {
"en": null,
"de": require("./loc/de.json")
};
const defaultLanguage = "en";
const appEntries = [
"react-hot-loader/patch",
"whatwg-fetch",
"./src/index.tsx",
];
const config = (lang) => {
return {
entry: {
app: appEntries
},
output: {
path: path.join(__dirname, "dist"),
filename: (lang || defaultLanguage) + ".[name]" + (process.env.NODE_ENV === "production" ? ".[githash]" : "") + ".js",
publicPath: "/",
sourceMapFilename: "[name].[hash].js.map"
},
devtool: "inline-source-map",
resolve: {
extensions: ["", ".webpack.js", ".web.js", ".tsx", ".ts", ".js"]
},
externals: [{
xmlhttprequest: '{XMLHttpRequest:XMLHttpRequest}'
}],
plugins: plugins.concat([
new I18nPlugin(languages[lang])]),
devServer: {
historyApiFallback: { index: "/" },
contentBase: "./src"
},
module: {
preLoaders: [
loaders.tslint,
],
loaders: [
loaders.json,
loaders.tsx,
loaders.html,
loaders.scss,
loaders.svg,
loaders.eot,
loaders.woff,
loaders.woff2,
loaders.ttf,
{ test: /jquery\.js$/, loader: "expose?jQuery!expose?$" }
]
}
};
};
// Uncomment to only build english
if (process.env.NODE_ENV === "development" || process.env.TEST) {
module.exports = config("en");
} else {
module.exports = Object.keys(languages).map(lang => config(lang));
}