-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
executable file
·74 lines (70 loc) · 1.74 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
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const PATHS = {
SRC: path.resolve(__dirname, 'src'),
DIST: path.resolve(__dirname, 'dist'),
PHASERMODULE: path.resolve(__dirname, 'node_modules', 'phaser-ce')
}
PATHS.PHASER = path.join(PATHS.PHASERMODULE, 'build/custom/phaser-split.js')
PATHS.PIXI = path.join(PATHS.PHASERMODULE, 'build/custom/pixi.js'),
PATHS.P2 = path.join(PATHS.PHASERMODULE, 'build/custom/p2.js')
module.exports = {
entry: {
game: [path.join(PATHS.SRC, 'main.js')],
vendor: ['pixi', 'p2', 'phaser']
},
output: {
path: PATHS.DIST,
filename: 'game.bundle.js'
},
devServer: {
contentBase: PATHS.SRC
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'/* chunkName= */,
filename: 'vendor.bundle.js'/* filename= */
}),
new HtmlWebpackPlugin({
template: path.join(PATHS.SRC, 'index.html')
}),
new CopyWebpackPlugin([{
from: path.join(PATHS.SRC, 'assets'),
to: path.join(PATHS.DIST, 'assets')
}, {
from: 'CNAME',
to: path.join(PATHS.DIST)
}], {})
],
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}]
}, {
test: /pixi\.js/,
use: ['expose-loader?PIXI']
}, {
test: /phaser-split\.js$/,
use: ['expose-loader?Phaser']
}, {
test: /p2\.js/,
use: ['expose-loader?p2']
}]
},
resolve: {
alias: {
'phaser': PATHS.PHASER,
'pixi': PATHS.PIXI,
'p2': PATHS.P2
},
extensions: ['.js']
}
}