-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.ts
85 lines (82 loc) · 1.99 KB
/
webpack.config.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
78
79
80
81
82
83
84
85
/// <reference path="node_modules/webpack-dev-server/types/lib/Server.d.ts"/>
import HtmlWebPackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import type { Configuration } from 'webpack';
import webpack from 'webpack';
import path from 'path';
const config: Configuration = {
devServer: {
host: 'localhost',
hot: true,
static: [path.resolve(__dirname, 'src', 'assets')],
},
entry: {
main: path.resolve(__dirname, 'src/index.ts'),
},
resolve: {
extensions: ['.ts', '.js'],
plugins: [new TsconfigPathsPlugin()],
},
output: {
assetModuleFilename: 'images/[hash][ext][query]',
path: path.resolve(__dirname, 'dist'),
},
optimization: {
minimize: false,
minimizer: [],
},
plugins: [
new webpack.DefinePlugin({
WEBGL_RENDERER: true,
CANVAS_RENDERER: true,
USELOCALSTORAGE: true,
'typeof SHADER_REQUIRE': JSON.stringify(false),
'typeof CANVAS_RENDERER': JSON.stringify(true),
'typeof WEBGL_RENDERER': JSON.stringify(true),
}),
new HtmlWebPackPlugin({
template: './src/index.html',
}),
new MiniCssExtractPlugin(),
],
module: {
rules: [
{
test: /\.ts$/,
exclude: /\.tsx$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
},
{
test: [/\.vert$/, /\.frag$/],
type: 'asset/source',
},
{
test: [/\.(png|fnt|mp3|ogg)$/],
type: 'asset/resource',
generator: {
filename: 'assets/[name].[hash][ext]',
},
},
{
test: /\.json$/,
type: 'asset/resource',
generator: {
filename: '[name].[hash][ext]',
},
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
};
export default config;