-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.cjs
100 lines (99 loc) · 2.86 KB
/
webpack.config.cjs
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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserWebpackPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
module.exports = {
mode: 'production',
entry: './src/main.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
publicPath: '/',
libraryTarget: 'es',
umdNamedDefine: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
'@reduxjs/toolkit': path.resolve(
__dirname,
'node_modules/@reduxjs/toolkit'
),
'@types/react': path.resolve(__dirname, 'node_modules/@types/react'),
'@types/react-dom': path.resolve(
__dirname,
'node_modules/@types/react-dom'
),
'@types/styled-components': path.resolve(
__dirname,
'node_modules/@types/styled-components'
),
'@xmpp': path.resolve(__dirname, 'node_modules/@xmpp'),
axios: path.resolve(__dirname, 'node_modules/axios'),
ltx: path.resolve(__dirname, 'node_modules/ltx'),
react: path.resolve(__dirname, 'node_modules/react'),
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
'react-redux': path.resolve(__dirname, 'node_modules/react-redux'),
'react-scripts': path.resolve(__dirname, 'node_modules/react-scripts'),
redux: path.resolve(__dirname, 'node_modules/redux'),
'redux-saga': path.resolve(__dirname, 'node_modules/redux-saga'),
'styled-components': path.resolve(
__dirname,
'node_modules/styled-components'
),
uuid: path.resolve(__dirname, 'node_modules/uuid'),
'@types/lodash': path.resolve(__dirname, 'node_modules/@types/lodash'),
'@types/react-modal': path.resolve(
__dirname,
'node_modules/@types/react-modal'
),
'@types/uuid': path.resolve(__dirname, 'node_modules/@types/uuid'),
'@types/xmpp__client': path.resolve(
__dirname,
'node_modules/@types/xmpp__client'
),
},
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[contenthash].[ext]',
outputPath: 'assets/images',
},
},
],
},
],
},
optimization: {
minimize: true,
minimizer: [
new TerserWebpackPlugin({
terserOptions: {
compress: {
drop_console: true,
},
},
}),
new CssMinimizerPlugin(),
],
splitChunks: {
chunks: 'all',
},
},
devtool: 'source-map',
};