This repository has been archived by the owner on Aug 28, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.ts
75 lines (69 loc) · 1.69 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 { resolve } from 'path'
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import webpack, { Configuration } from 'webpack'
const NODE_ENV =
(process.env.NODE_ENV as Configuration['mode']) || 'development'
const __DEV__ = NODE_ENV === 'development'
const config: Configuration = {
mode: NODE_ENV,
entry: './src/index.tsx',
output: {
path: resolve('docs'),
filename: `[name].[${__DEV__ ? 'hash' : 'contenthash'}].js`,
},
devtool: __DEV__ ? 'cheap-module-eval-source-map' : false,
resolve: {
alias: {
lodash$: 'lodash-es',
'react-translator': resolve('lib'),
},
extensions: ['.ts', '.tsx', '.js'],
modules: [resolve('src'), 'node_modules'],
},
module: {
rules: [
{
test: /\.pug$/,
use: ['html-loader', 'pug-plain-loader'],
},
{
test: /\.tsx?$/,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
],
},
],
},
optimization: {
splitChunks: {
name: 'vendors',
chunks: 'all',
cacheGroups: {
vendors: {
test: ({ context, request }: { context: string; request: string }) =>
/node_modules/.test(context) && !/\.css$/.test(request),
},
},
},
runtimeChunk: {
name: 'manifest',
},
},
plugins: [
new webpack.DefinePlugin({
__DEV__,
I18N_REGEX: /([\w-]*[\w]+)\.i18n\.json$/.toString(),
}),
new HtmlWebpackPlugin({
template: 'src/index.pug',
}),
new ForkTsCheckerWebpackPlugin(),
],
}
export default config