This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
webpack.config.js
124 lines (113 loc) · 3.65 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const { resolve } = require('path');
const { cpus } = require('os');
const webpack = require('webpack');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const afterEmitPlugin = require('./tools/AfterEmitPlugin');
module.exports = {
entry: resolve(__dirname, '.tmp/registry.tsx'),
watch: true,
devtool: 'inline-cheap-source-map',
output: {
path: resolve(__dirname, 'dist'),
filename: 'index.js'
},
resolve: {
modules: ['node_modules'],
extensions: [
'.js',
'.json',
'.ts',
'.tsx',
'.scss'
]
},
module: {
rules: [
{
test: /\.scss$/u,
use: [
'style-loader',
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
config: { path: resolve('./postcss.config') },
sourceMap: true
}
}
]
},
{
test: /\.(ts|tsx)$/u,
use: [
{
loader: 'thread-loader',
options: {
workers: cpus().length - 2
}
},
{
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: {
ie: 11,
chrome: 55,
ios: 9,
android: 4
},
modules: false,
loose: true
}
],
'@babel/preset-react'
],
plugins: [
'babel-plugin-transform-react-remove-prop-types',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-react-constant-elements',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-object-assign'
]
}
},
{
loader: 'ts-loader',
options: { happyPackMode: true }
}
]
},
{
test: /\.inline\.\w+$/u,
loader: 'raw-loader'
}
]
},
plugins: [
new webpack.DefinePlugin({
process: { env: JSON.stringify(process.env) }
}),
new ForkTsCheckerWebpackPlugin({
checkSyntacticErrors: true,
tsconfig: resolve(__dirname, 'tsconfig.json')
}),
new MiniCssExtractPlugin({
filename: 'index.css'
}),
afterEmitPlugin()
],
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
},
performance: {
hints: false
},
mode: 'development'
};