-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
114 lines (113 loc) · 2.66 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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
module.exports = {
mode: 'production',
entry: {
'tyk-ui': path.resolve(__dirname, 'src/index.js'),
index: path.resolve(__dirname, 'src/index.js'),
},
output: {
path: path.resolve(__dirname, './lib/'),
filename: '[name].js',
library: {
type: 'commonjs2',
},
publicPath: '',
},
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
module: {
rules: [
{
test: /\.js?$/,
include: [
path.resolve(__dirname, 'src'),
],
exclude: /(node_modules)/,
loader: 'esbuild-loader',
options: {
loader: 'jsx',
target: 'es2015',
},
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
exclude: [/images/],
type: 'asset/resource',
generator: {
filename: ({ filename }) => path.relative('src/common', filename),
},
},
{
test: /\.(png|svg|jpg|gif)$/,
exclude: [/fonts/],
type: 'asset/resource',
generator: {
filename: 'images/[name][ext]',
},
},
{
test: /worker-.*\.js/,
include: [/node_modules\/ace-build/],
type: 'asset/resource',
},
],
},
optimization: {
minimize: true,
minimizer: [
'...',
new CssMinimizerPlugin(),
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new CopyWebpackPlugin({
patterns: [
{
from: '**/*.scss',
to: 'sass/',
context: 'src/',
},
],
}),
new ESLintPlugin({
fix: true,
lintDirtyModulesOnly: true,
}),
],
devtool: 'source-map',
externals: {
react: 'commonjs2 react',
'react-dom': 'commonjs2 react-dom',
'react-ace': 'commonjs2 react-ace',
'react-datetime-picker': 'commonjs2 react-datetime-picker',
'react-transition-group': 'commonjs2 react-transition-group',
brace: 'commonjs2 brace',
echarts: 'commonjs2 echarts',
flatpickr: 'commonjs2 flatpickr',
immutable: 'commonjs2 immutable',
'prop-types': 'commonjs2 prop-types',
},
stats: 'verbose',
};