-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.client.config.js
100 lines (81 loc) · 1.76 KB
/
webpack.client.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const path = require("path")
const webpack = require("webpack")
// Production flag, turned on with the command-line flag
const __PRODUCTION__ = process.argv.indexOf("--production") > -1
// -- Webpack configuration --
const config = {}
// Application entry point
config.entry = {
gladius: "./src/client/js/index.js",
}
// Output files in the build/ folder
config.output = {
path: path.join(__dirname, "build", "public"),
filename: "[name].js",
publicPath: "/",
sourceMapFileName: "[file].map",
}
config.resolve = {
extensions: [
"",
".js",
".json",
],
}
config.module = {}
config.module.loaders = [
// Use babel and eslint to build and validate JavaScript
{
test: /\.js$/,
exclude: /node_modules/,
loaders: [
"babel?{stage:0}",
"eslint",
],
},
// Allow loading of JSON files
{
test: /\.json$/,
loader: "json",
},
// Use cssnext to build CSS
{
test: /\.css$/,
loader: "style!css!cssnext",
},
// Copy images
{
test: /\.(ico|jpe?g|png|gif)$/,
loader: "file?name=[path][name].[ext]&context=./src/client",
},
// Copy web fonts
{
test: /\.(woff|ttf|otf|eot\?#.+|svg#.+)$/,
loader: "file?name=[path][name].[ext]&context=./src/client",
},
// Copy HTML files
{
test: /\.html$/,
loader: "file?name=[path][name].[ext]&context=./src/client",
},
]
config.plugins = (
[]
)
// Optimize build in production
if (__PRODUCTION__) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
})
)
}
// cssnext-specific configuration
config.cssnext = {
sourcemap: !__PRODUCTION__,
compress: __PRODUCTION__,
}
config.devtool = __PRODUCTION__ ? "source-map" : "cheap-module-source-map"
module.exports = config