-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
/
Copy pathwebpack.config.js
69 lines (68 loc) · 1.93 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const webpackBaseConfig = require('../../webpackBaseConfig');
module.exports = {
...webpackBaseConfig,
entry: path.resolve(__dirname, 'index.js'),
mode: process.env.NODE_ENV || 'development',
optimization: {
// Helps debugging and build perf.
// Bundle size is irrelevant for local serving
minimize: false,
},
output: {
path: path.resolve(__dirname, './build'),
publicPath: '/',
filename: 'tests.js',
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './template.html'),
}),
// Avoid bundling the whole @mui/icons-material package. x2 the bundling speed.
new webpack.IgnorePlugin({ resourceRegExp: /material-icons\/SearchIcons\.js/ }),
new webpack.ProvidePlugin({
// required by enzyme > cheerio > parse5 > util
process: 'process/browser',
}),
],
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
configFile: path.resolve(__dirname, '../../babel.config.js'),
},
},
{
test: /\.md$/,
type: 'asset/source',
},
{
test: /\.(jpg|gif|png)$/,
type: 'asset/inline',
},
],
},
resolve: {
...webpackBaseConfig.resolve,
alias: {
...webpackBaseConfig.resolve.alias,
'@material-ui/core': path.resolve(__dirname, '../../packages/mui-material/src'),
'@material-ui/styles': path.resolve(__dirname, '../../packages/mui-styles/src'),
},
fallback: {
// needed by enzyme > cheerio
stream: false,
// required by enzyme > cheerio > parse5
util: require.resolve('util/'),
},
},
// TODO: 'browserslist:modern'
// See https://github.com/webpack/webpack/issues/14203
target: 'web',
};