forked from yearn/yearn-finance-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
78 lines (73 loc) · 2.22 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const SriPlugin = require('webpack-subresource-integrity');
const CracoAlias = require('craco-alias');
const metaConfig = require('./meta.config');
require('react-scripts/config/env');
const REACT_APP = /^REACT_APP_/i;
const isProd = process.env.NODE_ENV === 'production';
const isVeYfiEnv = process.env.REACT_APP_USE_VEYFI_ROUTES === 'true';
// NOTE: orders REACT_APP_ environment variables in alphabetical order for consistent build bundle
const reactAppProcessEnv = Object.keys(process.env)
.filter((key) => REACT_APP.test(key))
.sort()
.reduce((env, key) => {
env[key] = process.env[key];
return env;
}, {});
Object.keys(reactAppProcessEnv).forEach((key) => {
delete process.env[key];
process.env[key] = reactAppProcessEnv[key];
});
module.exports = {
babel: {
plugins: [
[
'babel-plugin-styled-components',
{
minify: false,
transpileTemplateLiterals: false,
},
],
['@babel/plugin-proposal-class-properties'],
],
},
webpack: {
plugins: {
add: [
new SriPlugin({
hashFuncNames: ['sha256', 'sha384'],
enabled: isProd,
}),
],
},
configure: (webpackConfig, { env, paths }) => {
const htmlWebpackPluginInstance = webpackConfig.plugins.find((plugin) => plugin instanceof HtmlWebpackPlugin);
if (htmlWebpackPluginInstance) {
const { title, meta } = metaConfig.getHtmlConfig(isVeYfiEnv);
htmlWebpackPluginInstance.options.title = title;
htmlWebpackPluginInstance.options.meta = meta;
}
// Webpack build issue with ledger package
// https://github.com/LedgerHQ/ledger-live/issues/763
webpackConfig.resolve = {
...webpackConfig.resolve,
alias: {
...webpackConfig.resolve.alias,
'@ledgerhq/devices/hid-framing': '@ledgerhq/devices/lib/hid-framing',
},
};
if (isProd) webpackConfig.output.crossOriginLoading = 'anonymous';
return webpackConfig;
},
},
plugins: [
{
plugin: CracoAlias,
options: {
source: 'tsconfig',
baseUrl: './src',
tsConfigPath: './tsconfig.paths.json',
},
},
],
};