-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
82 lines (70 loc) · 2.09 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
82
var path = require('path');
var minimist = require('minimist');
var webpack = require('webpack');
var TARGET = minimist(process.argv.slice(2)).TARGET || 'PROD';
const SERVER_URL = minimist(process.argv.slice(2)).SERVER_URL;
var HtmlWebpackPlugin = require('html-webpack-plugin');
var config = {
context: __dirname + '/src',
entry: [
'src/index.js'
],
resolve: {
root: [path.join(__dirname, "/"), path.join(__dirname, "/node_modules")]
},
module: {
loaders: [
{
test: /.*\.js$/, exclude: /node_modules/, loader: "babel-loader",
query: {
presets: ['es2015']
}
},
{test: /\.css$/, loader: "style!css"},
{test: /\.json$/, loader: "json"},
{test: /\.html$/, exclude: /node_modules/, loader: "raw"},
{test: /\.woff(2)?.*/, loader: "url?limit=10000&minetype=application/font-woff"},
{test: /\.(ttf|eot|svg).*/, loader: "file"},
{test: /\.(png|jpg|gif)$/, loader: 'url?limit=8192'}
]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
mangle: false
}),
new HtmlWebpackPlugin({
template: "index.html"
})
],
devServer: {
contentBase: "./src",
quiet: false,
noInfo: false,
stats: {colors: true},
hot: true,
port: 3000,
headers: {"X-Custom-Header": "yes"},
proxy: {
"/Token": {
target: SERVER_URL,
secure: false
},
"/api/*": {
target: SERVER_URL,
secure: false
}
}
},
// support source maps
devtool: TARGET === "DEV" ? "#cheap-module-eval-source-map" : "none"
};
if (TARGET !== "DEV") {
config.output = {
path: path.join(__dirname, "dist"),
filename: "bundle.[hash].js"
};
}
module.exports = config;