forked from Loopring/dexwebapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
79 lines (74 loc) · 2.42 KB
/
config-overrides.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
const webpack = require('webpack');
const {
override,
addWebpackPlugin,
fixBabelImports,
addLessLoader,
setWebpackOptimizationSplitChunks,
addWebpackAlias
} = require('customize-cra');
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
const path = require('path');
const GitRevisionPlugin = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();
// Deployment on Heroku
// During Heroku builds, the SOURCE_VERSION and STACK environment variables are set:
var onHeroku = process.env.SOURCE_VERSION && process.env.STACK;
// If we're on Heroku, we don't have access to the .git directory so we can't
// rely on git commands to get the version. What we *do* have during Heroku
// builds is a SOURCE_VERSION env with the git SHA of the commit being built,
// so we can use that instead to generate the version file.
function getCommitHash() {
try {
return onHeroku ? process.env.SOURCE_VERSION : gitRevisionPlugin.commithash();
} catch (error) {
return ""
}
}
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
module.exports = override(
addWebpackAlias({
// lodash: path.resolve(__dirname, 'node_modules/lodash'),
'bn.js': path.resolve(__dirname, 'node_modules/bn.js/lib/bn.js')
}),
addWebpackPlugin(new AntdDayjsWebpackPlugin()),
addWebpackPlugin(
new DuplicatePackageCheckerPlugin({
verbose: true,
strict: true
})
),
// addWebpackPlugin(gitRevisionPlugin),
addWebpackPlugin(
new webpack.DefinePlugin({
'process.env.COMMITHASH': JSON.stringify(getCommitHash()),
'process.env.TIME':
'"' +
new Date().toLocaleString('en-US', { timeZone: 'Asia/Hong_Kong' }) +
'/SH"'
})
),
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true
}),
setWebpackOptimizationSplitChunks({
// https://webpack.js.org/plugins/split-chunks-plugin/
chunks: 'async',
maxSize: 4000000,
maxAsyncRequests: 8,
maxInitialRequests: 6
}),
addLessLoader({
javascriptEnabled: true,
// https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
modifyVars: {
'@font-family': 'Montserrat, sans-serif',
'@btn-shadow': '0px',
'@animation-duration-slow': '0s !important',
'@wave-animation-width': '0px',
'@modal-body-padding': '16px 60px 32px 60px'
}
})
);