-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
78 lines (75 loc) · 2.12 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
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import CopyPlugin from 'copy-webpack-plugin';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default {
mode: process.env.NODE_ENV ?? 'development',
entry: './src/index.tsx',
plugins: [
new HtmlWebpackPlugin({
template: 'public/index.html',
}),
new CopyPlugin({
patterns: [
{
from: 'public/static',
to: 'static',
},
{
from: 'public/favicon.ico',
},
],
}),
],
output: {
path: resolve(__dirname, 'dist'),
filename: 'main.js',
publicPath: '/',
},
target: 'web',
devServer: {
port: process.env.PORT ?? '3001',
static: [ './dist' ],
open: true,
hot: true,
historyApiFallback: true,
},
resolve: {
extensions: [ '.tsx', '.ts', '.js','.jsx','.json' ],
},
module:{
rules: [
{
test: /\.(js|jsx)$/,
include: resolve(__dirname, 'src'),
use: 'babel-loader',
},
{
test: /\.(ts|tsx)$/,
include: resolve(__dirname, 'src'),
use: 'ts-loader',
},
{
test: /\.css$/,
include: resolve(__dirname, 'src/styles'),
use: [
'style-loader',
{
loader: 'css-loader',
options: {
url: false,
},
},
'postcss-loader',
],
},
{
test: /\.(glsl)(\.template)?$/,
include: resolve(__dirname, 'src'),
type: 'asset/source',
},
],
},
};