-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
85 lines (83 loc) · 2.16 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
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
const webpack = require('webpack');
const pkg = require('./package.json');
const publicFolder = `${__dirname}/public`;
const distFolder = `${publicFolder}/dist`;
const env = process.env.NODE_ENV || 'development';
module.exports = {
entry: env === 'production' ? `${publicFolder}/src/LandsWar.js` : `${publicFolder}/src/main.js`,
output: {
libraryTarget: 'var',
library: 'LandsWar',
path: distFolder,
filename: 'landswar-game.js',
},
module: {
rules: [
{
test: /\.png$/,
use: [
{
loader: 'base64-image-loader',
},
],
},
{
test: /\.js$/,
exclude: /(node_modules)/,
use: [
{
loader: 'babel-loader',
},
],
},
],
},
externals: {
phaser: 'Phaser',
io: 'io',
},
plugins: [
new webpack.EnvironmentPlugin({
TOKEN_PLAYER: null,
SHORTID_ROOM: null,
API_URL: 'http://0.0.0.0:3000',
WEBSOCKETS_URL: 'http://0.0.0.0:3000',
}),
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version),
}),
new HtmlWebpackPlugin({
title: 'LandsWar - game',
}),
new HtmlWebpackIncludeAssetsPlugin({
assets: [
'styles.css',
'phaser.min.js',
'socket.io.min.js',
],
append: false,
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: true,
},
sourceMap: true,
}),
new CopyWebpackPlugin([
{ from: './node_modules/phaser/build/phaser.min.js', to: `${distFolder}/phaser.min.js` },
{ from: './node_modules/socket.io-client/dist/socket.io.min.js', to: `${distFolder}/socket.io.min.js` },
{ from: `${publicFolder}/styles.css`, to: `${distFolder}/styles.css` },
{ from: `${publicFolder}/track-webfont.woff`, to: `${distFolder}/track-webfont.woff` },
{ from: `${publicFolder}/track-webfont.woff2`, to: `${distFolder}/track-webfont.woff2` },
]),
],
devServer: {
contentBase: distFolder,
compress: true,
port: process.env.WEBPACK_SERVER_PORT || 9000,
},
devtool: 'source-map',
};