-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.ts
83 lines (80 loc) · 1.92 KB
/
webpack.common.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
76
77
78
79
80
81
82
83
import dotenv from 'dotenv';
import os from 'os';
import path from 'path';
import { Configuration } from 'webpack';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import HTMLWebpackPlugin from 'html-webpack-plugin';
import { GenerateSW } from 'workbox-webpack-plugin';
dotenv.config();
const common: Configuration = {
entry: {
explorer: path.resolve(__dirname, 'src/client/wex/index.tsx'),
},
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist'),
},
optimization: {
splitChunks: {
name: 'vendor',
chunks: 'initial',
},
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.(tsx)?$/,
exclude: /node_modules/,
use: [
{ loader: 'cache-loader' },
{
loader: 'thread-loader',
options: {
workers: os.cpus().length - 1,
},
},
{
loader: 'ts-loader',
options: {
happyPackMode: true,
},
},
],
},
{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre',
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
new GenerateSW({
clientsClaim: true,
skipWaiting: true,
cleanupOutdatedCaches: true,
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts.googleapis.com/,
handler: 'StaleWhileRevalidate',
},
{
urlPattern: /\.woff2$/,
handler: 'StaleWhileRevalidate',
},
],
}),
new HTMLWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, 'src/client/wex/index.html'),
meta: {
viewport: 'minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no',
},
}),
],
};
export default common;