-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcraco.config.js
More file actions
62 lines (58 loc) · 1.76 KB
/
craco.config.js
File metadata and controls
62 lines (58 loc) · 1.76 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
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const WebpackBar = require('webpackbar');
const CracoAlias = require('craco-alias');
process.env.BROWSER = 'none';
module.exports = {
webpack: {
configure: (webpackConfig) => {
// Remove or modify the Prettier plugin
webpackConfig.plugins = webpackConfig.plugins.filter(plugin =>
!(plugin.constructor && plugin.constructor.name === 'PrettierPlugin')
);
webpackConfig.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
});
// Split chunks to avoid large files that cause ngrok issues
webpackConfig.optimization = {
...webpackConfig.optimization,
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
maxSize: 1024 * 1024, // 1MB max chunk size
},
common: {
minChunks: 2,
chunks: 'all',
maxSize: 1024 * 1024, // 1MB max chunk size
},
},
},
};
return webpackConfig;
},
plugins: [
new WebpackBar({ profile: true }),
...(process.env.NODE_ENV === 'development' ? [new BundleAnalyzerPlugin({ openAnalyzer: false })] : []),
],
},
plugins: [
{
plugin: CracoAlias,
options: {
source: 'tsconfig',
// baseUrl SHOULD be specified
// plugin does not take it from tsconfig
baseUrl: './src/',
/* tsConfigPath should point to the file where "baseUrl" and "paths"
are specified*/
tsConfigPath: './tsconfig.paths.json',
},
},
],
};