-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
87 lines (74 loc) · 2.02 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 HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
const phaserModule = path.join(__dirname, '/node_modules/phaser/')
const phaser = path.join(phaserModule, 'src/phaser.js')
module.exports = {
devtool: isProduction ? 'none' : 'inline-source-map',
entry: {
main: [
'./src/init.ts',
],
vendor: ['phaser']
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js'
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
alias: {
// general
phaser: phaser,
// assets
audio: path.resolve(__dirname, 'src/assets/audio/'),
fonts: path.resolve(__dirname, 'src/assets/fonts/'),
images: path.resolve(__dirname, 'src/assets/images/'),
sprites: path.resolve(__dirname, 'src/assets/sprites/'),
// src
config: path.resolve(__dirname, 'src/config/'),
prefabs: path.resolve(__dirname, 'src/prefabs/'),
typings: path.resolve(__dirname, 'src/typings/'),
objects: path.resolve(__dirname, 'src/objects/'),
scenes: path.resolve(__dirname, 'src/scenes/'),
store: path.resolve(__dirname, 'src/redux/'),
}
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader'
},
{
test: [/\.vert$/, /\.frag$/],
use: 'raw-loader'
}
]
},
optimization: {
splitChunks: {
name: 'vendor',
filename: 'vendor.bundle.js'
}
},
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')),
WEBGL_RENDERER: true,
CANVAS_RENDERER: true
}),
new HtmlWebpackPlugin({
title: 'Phaser Game Template',
template: './src/index.ejs',
chunks: ['vendor', 'main']
}),
new CopyWebpackPlugin({
patterns: [
{ from: 'src/assets/', to: 'assets/' }
],
})
]
}