-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
103 lines (100 loc) · 2.78 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
102
103
const path = require('path');
const { DefinePlugin } = require("webpack");
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const commitHash = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString()
.trim();
/**
* @type {import('webpack').Configuration}
*/
const config = {
entry:
{
main: './src/routes.tsx',
},
output: {
path: path.resolve('public'),
},
resolve: {
extensions: ['.js', '.ts', '.tsx'],
alias: {
src: path.resolve(__dirname, './src'),
"react": "preact/compat",
"react-dom": "preact/compat",
},
},
module: {
rules: [
{ test: /\.tsx?$/, use: 'babel-loader', exclude: /node_modules/ },
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
],
},
plugins: [
new DefinePlugin({
'process.env': {
COMMIT_HASH: JSON.stringify(commitHash),
},
}),
new HtmlWebpackPlugin({
template: './src/pages/usr/index.html',
filename: 'index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/sandbox/index.html',
filename: 'sandbox/index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/privacy/index.html',
filename: 'privacy/index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/blog/index.html',
filename: 'blog/index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/apps/index.html',
filename: 'apps/index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/apps/ticmetactoe/index.html',
filename: 'apps/ticmetactoe/index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/apps/takemeapart/index.html',
filename: 'apps/takemeapart/index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/apps/pokegrader/index.html',
filename: 'apps/pokegrader/index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/apps/guildvaults/index.html',
filename: 'apps/guildvaults/index.html',
inject: 'body',
}),
new HtmlWebpackPlugin({
template: './src/pages/blog/why-our-company-needed-web-components/index.html',
filename: 'blog/why-our-company-needed-web-components/index.html',
inject: 'body',
}),
new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
{ from: 'assets', to: 'assets' },
],
}),
],
};
module.exports = config;