This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
forked from gorilla-devs/GDLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
121 lines (113 loc) · 3.63 KB
/
craco.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
115
116
117
118
119
120
121
// const path = require("path");
// const alias = {
// app: path.resolve("./src/app/"),
// common: path.resolve("./src/common/"),
// ui: path.resolve("./src/ui/")
// };
/* eslint-disable no-param-reassign */
const CracoAntDesignPlugin = require('craco-antd');
// const SentryCliPlugin = require('@sentry/webpack-plugin');
// const os = require('os');
// const packageJson = require('./package.json');
module.exports = () => {
return {
babel: {
presets: [
[
'@babel/preset-env',
{
loose: true,
targets: {
node: '14'
}
}
],
'@babel/react'
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import',
'@loadable/babel-plugin',
'babel-plugin-macros',
[
'babel-plugin-styled-components',
{
ssr: true,
pure: true
}
]
]
},
webpack: {
devtool: 'eval-cheap-module-source-map',
configure: webpackConfig => {
webpackConfig.target =
process.env.APP_TYPE === 'electron' ? 'electron-renderer' : 'web';
// webpackConfig.output = {
// filename: isEnvProduction
// ? 'static/js/[name].js'
// : isEnvDevelopment && 'static/js/bundle.js',
// chunkFilename: isEnvProduction
// ? 'static/js/[name].chunk.js'
// : isEnvDevelopment && 'static/js/[name].chunk.js'
// };
webpackConfig.optimization.splitChunks = {
name: false,
chunks: 'all',
maxInitialRequests: Infinity,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]!(antd)/,
name(module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(
/[\\/]node_modules[\\/](.*?)([\\/]|$)/
)[1];
// npm package names are URL-safe, but some servers don't like @ symbols
return `npm.${packageName.replace('@', '')}`;
}
}
}
};
// if (process.env.SOURCE_MAPS_UPLOAD) {
// webpackConfig.plugins.push(
// new SentryCliPlugin({
// include: [
// './build/electron.js',
// './build/electron.js.map',
// './build/static/js/*'
// ],
// ignore: ['native'],
// org: 'gdlauncher',
// project: 'react',
// authToken: process.env.SENTRY_AUTH,
// url: process.env.SOURCE_MAPS_UPLOAD,
// release: packageJson.version,
// dist: `${process.env.REACT_APP_RELEASE_TYPE}-${os.platform()}`
// })
// );
// } else {
// console.log('Not a release. Skipping source maps upload.');
// }
webpackConfig.resolve.aliasFields = [];
webpackConfig.resolve.mainFields = ['module', 'main'];
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
react: 'preact/compat',
'react-dom/test-utils': 'preact/test-utils',
'react-dom': 'preact/compat', // Must be below test-utils
'react/jsx-runtime': 'preact/jsx-runtime'
};
return webpackConfig;
}
},
plugins: [
{
plugin: CracoAntDesignPlugin
}
]
};
};