-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
101 lines (98 loc) · 2.58 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
89
90
91
92
93
94
95
96
97
98
99
100
101
const { resolve } = require('path');
const CssExtract = require('mini-css-extract-plugin');
const Html = require('html-webpack-plugin');
const config = [{
name: "client",
entry: {
index: resolve(__dirname, "src/client/index.ts"),
demoIndex: resolve(__dirname, "src/client/demoIndex.ts")
},
mode: "production",
module: {
rules: [{
test: /\.tsx?$/,
use: [{
loader: 'ts-loader',
options: {
configFile: resolve(__dirname, "src/client/tsconfig.json")
}
}],
}, {
test: /\.css$/,
use: [CssExtract.loader, 'css-loader'],
}, {
test: /\.(vert|frag)$/,
use: ['raw-loader'],
}]
},
output: {
filename: "[name]-[chunkhash:8].js",
path: resolve(__dirname, "public/client")
},
plugins: [
new CssExtract({
filename: "[name]-[contenthash:8].css",
}),
new Html({
chunks: ['index'],
filename: resolve(__dirname, "public/client/index.html"),
title: 'rock3d client'
}),
new Html({
chunks: ['demoIndex'],
filename: resolve(__dirname, "public/client/demoIndex.html"),
title: 'rock3d demo player'
})
],
resolve: {
extensions: ['.js', '.ts', '.tsx']
}
}, {
name: "editor",
entry: {
index: resolve(__dirname, "src/editor/index.ts"),
},
mode: "production",
module: {
rules: [{
test: /\.tsx?$/,
use: [{
loader: 'ts-loader',
options: {
configFile: resolve(__dirname, "src/editor/tsconfig.json")
}
}],
}, {
test: /\.css$/,
use: [CssExtract.loader, 'css-loader'],
}, {
test: /\.(vert|frag)$/,
use: ['raw-loader'],
}]
},
output: {
filename: "[name]-[chunkhash:8].js",
path: resolve(__dirname, "public/editor")
},
plugins: [
new CssExtract({
filename: "[name]-[contenthash:8].css",
}),
new Html({
chunks: ['index'],
filename: resolve(__dirname, "public/editor/index.html"),
title: "rocked"
}),
],
resolve: {
extensions: ['.js', '.ts', '.tsx']
}
}];
module.exports = (_, argv) => {
if (argv.mode === "development") {
for (const c of config) {
c.devtool = "source-map";
}
}
return config;
}