-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
104 lines (97 loc) · 2.5 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
function getEntrySources(sources) {
if (process.env.NODE_ENV !== 'production') {
sources.push('webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000');
}
return sources;
}
const basePlugins = [
new webpack.DefinePlugin({
__DEV__: process.env.NODE_ENV !== 'production',
__PRODUCTION__: process.env.NODE_ENV === 'production',
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new HtmlWebpackPlugin({
inject: 'body',
template: 'src/client/index.html'
})
];
const devPlugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
];
const prodPlugins = [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
];
const plugins = basePlugins
.concat(process.env.NODE_ENV === 'production' ? prodPlugins : [])
.concat(process.env.NODE_ENV === 'development' ? devPlugins : []);
module.exports = {
entry: {
game: getEntrySources(['./src/client/index.js'])
},
output: {
path: path.join(__dirname, 'dist/client'),
filename: '[name].[hash].js',
publicPath: '/',
sourceMapFilename: '[name].[hash].js.map',
chunkFilename: '[id].chunk.js'
},
resolve: {
alias: {
'pixi': path.join(__dirname, 'src/client/vendor/pixi'),
'phaser': path.join(__dirname, 'src/client/vendor/phaser'),
'resources': path.join(__dirname, 'resources'),
'shared': path.join(__dirname, 'src/shared')
},
extensions: ['', '.js', '.jsx']
},
devtool: 'source-map',
plugins: plugins,
module: {
preLoaders: [
{
test: /\.jsx?$/,
loader: 'source-map'
}
],
loaders: [
{
test: /\.jsx?$/,
loader: 'babel?cacheDirectory=true!eslint',
exclude: /(node_modules|src\/client\/vendor)/
},
{
test: /phaser\.js$/,
loader: 'imports?PIXI=pixi'
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.scss$/,
loader: 'style!css!sass?sourceMap'
},
{
test: /\.(png|jpg|jpeg|gif|svg)$/,
loader: 'url?prefix=img/&limit=5000'
},
{
test: /\.(mp3|ogg|wav)$/,
loader: 'url?prefix=audio/&limit=8192'
},
{
test: /\.(woff|woff2|ttf|eot)?$/,
loader: 'url?prefix=font/&limit=5000&mimetype=application/font-woff'
}
]
}
};