This repository has been archived by the owner on Aug 13, 2019. It is now read-only.
/
webpack.config.js
87 lines (83 loc) · 2.5 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
82
83
84
85
86
87
const path = require("path");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const PrettierPlugin = require("prettier-webpack-plugin");
const { getIfUtils, removeEmpty } = require("webpack-config-utils");
const { ifDev, ifProduction } = getIfUtils(process.env.NODE_ENV);
// 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");
const clientScripts = path.resolve(__dirname, "client");
module.exports = {
context: path.resolve(__dirname, "./client"),
devtool: "source-map",
stats: "minimal",
entry: {
gameApp: "./GameApp/index.jsx",
scoresApp: "./ScoreApp/index.jsx"
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "./dist/"),
publicPath: "/public/"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
include: clientScripts,
exclude: [/node_modules/],
use: [
{
loader: "babel-loader",
options: {
presets: ["es2015", "react", "flow"],
plugins: [
"transform-object-rest-spread",
"babel-plugin-transform-class-properties"
]
}
},
"eslint-loader"
]
},
{
test: /\.(css|scss)$/,
include: clientScripts,
exclude: [/node_modules/],
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader", "sass-loader"]
})
},
{
test: /\.(eot|svg|ttf|woff|woff2|png|mp3|json)$/,
include: clientScripts,
exclude: [/node_modules/],
loader: "file-loader?name=[name].[ext]"
},
{ test: /pixi\.js/, use: ["expose-loader?PIXI"] },
{ test: /phaser-split\.js$/, use: ["expose-loader?Phaser"] },
{ test: /p2\.js/, use: ["expose-loader?p2"] }
]
},
plugins: removeEmpty([
new ExtractTextPlugin("application.css"),
new webpack.DefinePlugin({
"process.env.NODE_ENV": ifProduction('"production"', '"development"'),
"process.env.JUMP_ON": JSON.stringify(process.env.JUMP_ON)
}),
ifDev(new PrettierPlugin()),
ifProduction(new webpack.optimize.UglifyJsPlugin())
]),
resolve: {
alias: {
phaser,
pixi,
p2
},
extensions: [".js", ".jsx"]
}
};