-
Notifications
You must be signed in to change notification settings - Fork 2
/
craco.config.js
116 lines (105 loc) · 3.01 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
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
const invariant = require("tiny-invariant");
const webpack = require("webpack");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const buildStartTS = Math.floor(new Date().getTime() / 1_000);
module.exports = {
babel: {
presets: [
[
"@babel/preset-react",
{ runtime: "automatic", importSource: "@emotion/react" },
],
],
plugins: [
"babel-plugin-react-icons",
"@emotion/babel-plugin",
"babel-plugin-twin",
"babel-plugin-macros",
[
"@simbathesailor/babel-plugin-use-what-changed",
{
active: process.env.NODE_ENV === "development", // boolean
},
],
],
},
webpack: {
configure: (
/** @type {import("webpack").Configuration} */
config,
) => {
invariant(config.plugins, "plugins");
invariant(config.module?.rules, "rules");
config.ignoreWarnings = [/Failed to parse source map/];
// pushing here ensures that the dotenv is loaded
if (process.env.ANALYZE) {
config.plugins.push(
new BundleAnalyzerPlugin({ analyzerMode: "server" }),
);
}
config.resolve = {
...config.resolve,
fallback: {
assert: false,
crypto: false,
stream: false,
},
};
config.plugins.unshift(
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
);
config.resolve = {
...config.resolve,
fallback: {
...config.resolve?.fallback,
url: require.resolve("url/"),
},
};
config.module.rules.push({
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
});
// solana wallet adapter, ledger need to be transpiled
config.module.rules.push({
test: /\.js/,
loader: require.resolve("babel-loader"),
include: [/@solana\/wallet-adapter/, /@ledgerhq\/devices/],
});
if (process.env.SENTRY_AUTH_TOKEN) {
config.plugins.push(
new SentryWebpackPlugin({
// sentry-cli configuration
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
release: process.env.REACT_APP_SENTRY_RELEASE ?? "unknown",
// webpack specific configuration
include: "./build/",
ignore: ["node_modules"],
setCommits: {
repo: process.env.GITHUB_REPO,
commit:
process.env.GITHUB_SHA ??
process.env.COMMIT_REF ??
process.env.CF_PAGES_COMMIT_SHA,
},
deploy: {
env: process.env.REACT_APP_SENTRY_ENV ?? "unknown",
started: buildStartTS,
},
}),
);
}
return config;
},
},
eslint: {
enable: false,
},
typescript: { enableTypeChecking: false },
};