forked from gnosis/cowswap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
72 lines (65 loc) · 2.14 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')
const SentryWebpackPlugin = require('@sentry/webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const { version } = require('./package.json')
// see https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md#configuration-overview
const plugins = []
const SENTRY_AUTH_TOKEN = process.env.REACT_APP_SENTRY_AUTH_TOKEN
const SENTRY_RELEASE_VERSION = 'CowSwap@v' + version
const ANALYZE_BUNDLE = process.env.REACT_APP_ANALYZE_BUNDLE
if (ANALYZE_BUNDLE) {
plugins.push(new BundleAnalyzerPlugin())
}
if (SENTRY_AUTH_TOKEN) {
plugins.push(
new SentryWebpackPlugin({
// sentry-cli configuration - can also be done directly through sentry-cli
// see https://docs.sentry.io/product/cli/configuration/ for details
authToken: SENTRY_AUTH_TOKEN,
org: 'cowprotocol',
project: 'cowswap',
release: SENTRY_RELEASE_VERSION,
// other SentryWebpackPlugin configuration
include: '.',
ignore: ['node_modules', 'webpack.config.js'],
})
)
}
module.exports = {
babel: {
plugins: [
'@babel/plugin-proposal-nullish-coalescing-operator',
[
'@simbathesailor/babel-plugin-use-what-changed',
{
active: process.env.NODE_ENV === 'development', // boolean
},
],
],
},
webpack: {
plugins,
alias: {
'@src': path.resolve(__dirname, 'src'),
'bn.js': path.resolve(__dirname, 'node_modules/bn.js/lib/bn.js'),
},
// https://webpack.js.org/configuration
configure: (webpackConfig) => ({
...webpackConfig,
resolve: {
...webpackConfig.resolve,
modules: [path.resolve(__dirname, 'src/custom'), ...webpackConfig.resolve.modules],
},
}),
},
devServer: (config) => {
// Add CORS headers, to enable to add the local served website in Gnosis Safe
config.headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
}
return config
},
}