-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
75 lines (73 loc) · 1.87 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
import path from 'path'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import atImport from 'postcss-import'
import autoprefixer from 'autoprefixer'
import webpack from 'webpack'
import FlowStatusWebpackPlugin from 'flow-status-webpack-plugin'
function genConfig(name: string): Object {
return {
devtool: 'eval-source-map',
entry: [
'react-hot-loader/patch',
path.join(__dirname, `app/client/${name}/index.js`),
`webpack-hot-middleware/client?reload=false&path=/${name}/hot`,
'webpack/hot/dev-server',
],
output: {
path: path.resolve('./dist'),
filename: `${name}.js`,
publicPath: `/${name}`,
},
resolve: {
root: path.resolve(__dirname),
alias: {
client: 'app/client',
common: 'app/common',
game: 'app/client/game',
player: 'app/client/player',
server: 'app/server',
styles: 'app/styles',
},
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
},
{
test: /\.jsx$/,
loaders: ['babel'],
include: path.join(__dirname, 'app'),
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
"style",
"css!sass!postcss"
),
},
],
postcss: [
atImport({
path: ['node_modules', './app',],
}),
autoprefixer({ add: false, browsers: [] }),
],
},
plugins: [
new ExtractTextPlugin(`${name}.css`),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new FlowStatusWebpackPlugin({
restartFlow: false,
})
],
}
}
module.exports = {
gameConfig: genConfig('game'),
playerConfig: genConfig('player'),
}