forked from e27813176/MathFox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
132 lines (130 loc) · 3.07 KB
/
webpack.common.js
File metadata and controls
132 lines (130 loc) · 3.07 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin')
const WebpackCleanPlugin = require('webpack-clean-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
// Phaser webpack config
const phaserModule = path.join(__dirname, '/node_modules/phaser-ce/')
const phaser = path.join(phaserModule, 'build/custom/phaser-split.js')
const pixi = path.join(phaserModule, 'build/custom/pixi.js')
const p2 = path.join(phaserModule, 'build/custom/p2.js')
module.exports = {
entry: {
app: [
'babel-polyfill',
path.resolve(__dirname, 'public/javascript/math_game/js/main.js'),
],
vendor: ['pixi', 'p2', 'phaser'],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor'/* chunkName= */, filename: '[hash].vendor.bundle.js'/* filename= */ }),
new WebpackCleanPlugin({
on: "emit",
path: ['./dist']
}),
new ExtractTextPlugin("styles.css"),
new HtmlWebpackExternalsPlugin({
externals: [
{
module: 'jquery',
entry: 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
global: 'jQuery',
}
]
})
],
module: {
rules: [
{
test: /\.js$/,
use: ['babel-loader?compact=false', 'eslint-loader'],
include: path.join(__dirname, 'public')
},
{
test: /.*\.(gif|png|jpe?g)$/i,
use: [
{
loader: 'file-loader',
options: {
name: 'images/[path][name]_[hash:7].[ext]',
}
}
]
},
{
test: /\.mp3$/,
use: [
{
loader: 'file-loader',
options: {
name: 'audio/[name].[ext]',
}
}
]
},
{
test: /\.json$/,
use: [
{
loader: 'json-loader',
}
]
},
/*
{
test: /.*\.(gif|png|jpe?g|mp3)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 10000000
}
}
]
},
*/
/*
{
test: /.*\.(gif|png|jpe?g)$/i,
use: [
{
loader: 'image-webpack-loader',
options: {
bypassOnDebug: true,
},
}
]
},
*/
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{ test: /pixi\.js/, use: ['expose-loader?PIXI'] },
{ test: /phaser-split\.js$/, use: ['expose-loader?Phaser'] },
{ test: /p2\.js/, use: ['expose-loader?p2'] }
]
},
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
},
externals: {
jquery: 'jQuery',
Analytics: 'Analytics',
globalUser: 'globalUser',
getPassedStageIDList: 'getPassedStageIDList',
path_prefix: 'path_prefix'
},
resolve: {
alias: {
'phaser': phaser,
'pixi': pixi,
'p2': p2
}
}
}