-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
75 lines (72 loc) · 1.74 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
import HtmlWebpackPlugin from 'html-webpack-plugin';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import CompressionPlugin from 'compression-webpack-plugin';
import { Configuration } from 'webpack';
import path from 'path';
const devServer = {
contentBase: `${__dirname}/dist`,
compress: true,
publicPath: 'public',
port: process.env.PORT || 1234,
writeToDisk: true,
historyApiFallback: true,
overlay: {
errors: true,
warnings: true,
},
open: true,
};
const config: Configuration & { devServer: typeof devServer } = {
entry: `${__dirname}/src/index.tsx`,
output: {
path: `${__dirname}/dist`,
filename: '[fullhash].js',
chunkFilename: '[chunkhash].js',
},
module: {
rules: [
{
test: /\.(ts|js)x?/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.(sc|c)ss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(png|svg|jpg|jpeg|gif|svg)$/,
type: 'asset/resource',
},
],
},
resolve: {
modules: ['node_modules', 'src'],
extensions: ['.ts', '.tsx', '.js', ',jsx'],
},
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
{ from: path.join(process.cwd(), '/public/assets'), to: 'assets' },
],
}),
new HtmlWebpackPlugin({
template: 'public/index.html',
minify: true,
favicon: 'src/assets/images/terminal.png',
meta: {
'theme-color': '#222222',
},
}),
// @ts-ignore
new CompressionPlugin({
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8,
}),
],
devServer,
};
export default config;