-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
57 lines (56 loc) · 1.42 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
var debug = process.env.NODE_ENV !== "production";
var webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: "./src/index.html",
filename: "index.html",
inject: "body"
});
const path = require("path");
module.exports = {
mode: debug ? "development" : "production",
context: __dirname,
devServer: {
historyApiFallback: {
rewrites: [{ from: /^\$/, to: path.join(__dirname, "index.html") }]
},
hot: true,
contentBase: path.join(__dirname, "assets"),
clientLogLevel: "error",
stats: "errors-only",
open: true
},
devtool: debug ? "inline-sourcemap" : null,
entry: "./src/app.js",
output: {
path: __dirname + "/dist/js",
filename: "bundle.min.js"
},
module: {
rules: [
{
test: /\.js(x?)$/,
exclude: /node_modules/,
use: "babel-loader"
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ["file-loader"]
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
plugins: debug
? [HtmlWebpackPluginConfig, new webpack.HotModuleReplacementPlugin()]
: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
mangle: false,
sourcemap: false
})
]
};