-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathwebpack.config.js
More file actions
95 lines (85 loc) · 2.13 KB
/
webpack.config.js
File metadata and controls
95 lines (85 loc) · 2.13 KB
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
/* eslint-env node */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
const mode = process.env.NODE_ENV || 'development';
const packageJson = require('./package.json');
const path = require('path');
const webpack = require('webpack');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
module.exports = {
mode,
entry: './src/index.tsx',
module: {
rules: [
{
test: /\.(eot|gif|jpg|png|svg|ttf|woff|woff2)$/,
type: 'asset/inline',
},
{
test: /\.css$/,
exclude: /src/,
include: /node_modules/,
use: ['css-loader'],
},
{
test: /\.css$/,
include: /src/,
exclude: /node_modules/,
use: [
'style-loader',
'@teamsupercell/typings-for-css-modules-loader',
{
loader: 'css-loader',
options: {
modules: true
}
},
],
},
{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
include: /src/,
loader: 'ts-loader',
options: {
compilerOptions: {
declaration: mode == 'development',
declarationMap: mode == 'development',
},
},
},
],
},
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(packageJson.version),
}),
new ESLintPlugin({
fix: true,
emitWarning: mode == 'development',
}),
// do not reload on autogeneratd css type def files change
new webpack.WatchIgnorePlugin({
paths: [/css\.d\.ts$/]
}),
],
optimization: {
minimizer: [
new TerserJSPlugin({
extractComments: true,
parallel: true,
}),
new CssMinimizerPlugin(),
],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'app.bundle.js',
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
};