forked from adazzle/react-data-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
106 lines (94 loc) · 2.56 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
import { resolve } from 'node:path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
import postcssNested from 'postcss-nested';
// TODO: remove `target` https://github.com/storybookjs/storybook/issues/15882
const target = 'browserslist:browserslist config, not maintained node versions';
export default (env, { mode }) => {
const isDev = mode === 'development';
return {
target,
entry: './website/root.tsx',
output: {
clean: true,
filename: isDev ? '[name].js' : '[name].[contenthash].js',
chunkFilename: isDev ? '[name].js' : '[contenthash].js'
},
devtool: isDev ? 'eval-cheap-module-source-map' : 'source-map',
devServer: {
open: true,
client: {
overlay: false
},
static: false
},
stats: {
assets: false,
entrypoints: false,
modules: false
},
performance: {
hints: false
},
resolve: {
alias: {
lodash: resolve('./node_modules/lodash-es')
},
extensions: ['.js', '.ts', '.tsx']
},
optimization: {
splitChunks: {
chunks: 'all'
},
minimizer: ['...', new CssMinimizerPlugin()]
},
module: {
strictExportPresence: true,
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: { plugins: [isDev && 'react-refresh/babel'].filter(Boolean) }
},
{
loader: '@linaria/webpack5-loader',
options: { preprocessor: 'none' }
}
]
},
{
test: /\.css$/,
use: [
isDev ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [postcssNested({ bubble: ['layer'] })]
}
}
}
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './website/index.html'
}),
isDev && new ReactRefreshWebpackPlugin({ overlay: false }),
!isDev &&
new MiniCssExtractPlugin({
filename: '[contenthash].css',
chunkFilename: '[contenthash].css',
ignoreOrder: true
})
].filter(Boolean)
};
};