-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
81 lines (75 loc) · 2.27 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
const path = require('path')
const BannerPlugin = require('./webpack_plugins/BannerPlugin')
const DefinePlugin = require('webpack').DefinePlugin
const WebpackObfuscator = require('webpack-obfuscator')
let config = {
mode: 'development',
entry: './src/Game.js',
output: {
filename: 'igloo-sandbox.js',
path: path.resolve(__dirname, 'assets/scripts/client')
},
optimization : {
minimize: false
},
devServer: {
static: {
directory: path.join(__dirname),
publicPath: '/'
},
devMiddleware: {
writeToDisk: true
},
host: 'localhost',
port: 8888,
hot: false,
liveReload: false
},
resolve: {
alias: {
'@engine': path.resolve(__dirname, 'src/engine'),
'@scenes': path.resolve(__dirname, 'src/scenes'),
'@components': path.resolve(__dirname, 'src/scenes/components'),
'@rooms': path.resolve(__dirname, 'src/scenes/rooms'),
'@games': path.resolve(__dirname, 'src/scenes/games'),
'@igloos': path.resolve(__dirname, 'src/scenes/igloos'),
'@parties': path.resolve(__dirname, 'src/scenes/parties')
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
},
plugins: [
new DefinePlugin({
VERSION: JSON.stringify(require('./package.json').version)
})
]
}
module.exports = (env, argv) => {
config.output.filename = 'igloo-sandbox.min.js'
if (argv.mode === 'production') {
config.optimization.minimize = true
if (env.obfuscate === 'true') {
config.plugins.push(
new WebpackObfuscator({
rotateStringArray: true,
reservedStrings: ['\s*']
}, [])
)
}
config.plugins.push(
new BannerPlugin({
banner: `Igloo Sandbox ${require('./package.json').version}. Some content from https://github.com/wizguin/yukon. License: MIT. ${new Date().toISOString()}`
})
)
}
return config
}