This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
101 lines (100 loc) · 3.22 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
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
module: {
rules: [
{
test: /\.ts?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
presets: [
['@babel/preset-env', { targets: 'maintained node versions' }],
'@babel/preset-typescript'
],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }]
]
}
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
babelrc: false,
presets: [
['@babel/preset-env', { targets: { browsers: 'last 2 versions ' } }],
'@babel/preset-typescript',
'@babel/preset-react'
],
plugins: [
["react-hot-loader/babel"],
['@babel/plugin-proposal-class-properties', { loose: true }]
]
}
},
{
test: /\.s[ac]ss$/i,
loaders: ['sass-loader']
},
{
test: /\.css$/,
loaders: ['css-loader']
},
{
test: /\.(gif|png|jpe?g|svg)$/,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
disable: false
}
}
]
},
// TODO why do we still need to inline import these?
{
test: /\.(md|txt)$/,
loaders: [
'html-loader',
'raw-loader'
]
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader'
}
]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json']
},
devtool: 'source-map',
plugins: [
new CleanWebpackPlugin(),
new ForkTsCheckerWebpackPlugin({
reportFiles: ['src/main/**/*']
}),
new ForkTsCheckerWebpackPlugin({
reportFiles: ['src/renderer/**/*']
}),
new webpack.NamedModulesPlugin(),
new HtmlWebpackPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'dev')
})
]
};