-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
88 lines (86 loc) · 2.2 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
88
const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const ForkTsCheckerPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
entry: './src/Main.ts',
module: {
rules: [
{
test: /\.[t|j]sx?$/,
loader: 'babel-loader',
options: {
babelrc: false,
cacheDirectory: true,
presets: [
[
'@babel/preset-typescript',
{
isTSX: true,
allExtensions: true,
jsxPragma: 'h',
},
],
],
plugins: [['@babel/transform-react-jsx', { pragma: 'h' }]],
},
},
{
test: /\.png$/,
type: 'asset/resource'
},
{
test: /\.wav$/,
type: 'asset/resource'
},
{
test: /\.pcss$/,
use: [ 'style-loader', 'css-loader', 'postcss-loader' ]
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx'],
alias: {
'react': 'preact/compat',
'react-dom': 'preact/compat',
'@res': path.resolve(__dirname, 'res')
},
},
devServer: {
host: '0.0.0.0',
setupMiddlewares: (middlewares, server) => {
const doc = `
<!DOCTYPE html>
<html lang='en'>
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Darumadrop+One&family=Roboto+Mono:wght@100;700&display=swap" rel="stylesheet">
<style>
body {
margin: 0;
}
canvas {
display: block;
}
</style>
</head>
<body id='root'/>
<script src='/main.js'></script>
</html>
`;
server.app.get('/', (_, res) => res.send(doc));
return middlewares;
},
},
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'build'),
},
plugins: [
new HTMLWebpackPlugin(),
new ForkTsCheckerPlugin({
typescript: { configFile: path.resolve(__dirname, 'tsconfig.json') }
})
]
};