-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
73 lines (67 loc) · 1.91 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
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
// Phaser webpack config
var phaserModule = path.join(__dirname, '/node_modules/phaser-ce/')
var phaser = path.join(phaserModule, 'build/custom/phaser-split.js')
var pixi = path.join(phaserModule, 'build/custom/pixi.js')
var p2 = path.join(phaserModule, 'build/custom/p2.js')
// http://stackoverflow.com/a/38733864
function isExternal(module) {
var userRequest = module.userRequest;
if (typeof userRequest !== 'string') {
return false;
}
return userRequest.indexOf('bower_components') >= 0 ||
userRequest.indexOf('node_modules') >= 0 ||
userRequest.indexOf('libraries') >= 0;
}
module.exports = {
context: __dirname + path.sep + 'src',
entry: './index.ts',
devtool: 'inline-source-map',
devServer: { inline: true },
output: {
path: __dirname + path.sep + 'dist',
filename: "[name].bundle.js",
chunkFilename: "[id].bundle.js"
},
module: {
loaders: [
// Some hacks to make loading phaser work
{ test: /pixi\.js/, loader: 'expose?PIXI' },
{ test: /phaser-split\.js$/, loader: 'expose?Phaser' },
{ test: /p2\.js/, loader: 'expose?p2' },
{ test: /\.tsx?$/, loader: 'ts-loader' },
{ test: /\.css$/, loader: ExtractTextPlugin.extract("css-loader") },
{ test: /\.png$/, loader: 'file-loader?name=[hash].[ext]' },
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors',
minChunks: function (module) {
return isExternal(module)
}
}),
new ExtractTextPlugin("[name].bundle.css"),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './index.template.html',
hash: true,
inject: true
})
],
resolve: {
alias: {
'phaser': phaser,
'pixi': pixi,
'p2': p2
},
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
},
node: {
fs: 'empty'
}
};