-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.ts
77 lines (72 loc) · 1.72 KB
/
webpack.common.ts
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
import type { Configuration } from "webpack";
import * as path from 'path';
const webpack = require("webpack");
// Phaser webpack config
const phaserModule = path.join(__dirname, '/node_modules/phaser/');
const phaser = path.join(phaserModule, 'src/phaser.js');
const config: Configuration = {
entry: {
app: path.resolve(__dirname, 'src/game.ts'),
vendor: ['phaser']
},
output: {
pathinfo: true,
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: 'bundle.[name].js',
assetModuleFilename: (pathData) => {
const filepath = path
.dirname(pathData.filename as string)
.split("/")
.slice(1)
.join("/");
return `${filepath}/[name].[hash][ext][query]`;
}
},
target: 'web',
module: {
rules: [
{
test: /\.ts$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
include: path.join(__dirname, 'src'),
presets: ['@babel/preset-env']
}
}
},
{
test: /\.(woff(2)?|ttf|eot|otf)$/,
type: 'asset/resource',
// generator: {
// filename: './fonts/[name][ext]',
// },
},
{
test: /\.(png|jpe?g|gif|svg|xml|mp3)$/i,
type: 'asset/resource'
}
]
},
plugins: [
new webpack.DefinePlugin({
CANVAS_RENDERER: JSON.stringify(true),
WEBGL_RENDERER: JSON.stringify(true)
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
],
resolve: {
extensions: ['.ts', '.js'],
alias: {
'phaser': phaser,
},
fallback: {
"buffer": require.resolve("buffer/")
}
}
};
export default config;