-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-overrides.js
70 lines (68 loc) · 1.67 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const {
override,
addWebpackModuleRule,
addWebpackPlugin,
addWebpackAlias,
} = require('customize-cra');
const ArcoWebpackPlugin = require('@arco-plugins/webpack-react');
const addLessLoader = require('customize-cra-less-loader');
const setting = require('./src/settings.json');
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require('webpack');
// get git info from command line
let commitHash = require('child_process')
.execSync('git rev-parse HEAD')
.toString()
.trim();
if (process.env.DEV_MODE) {
process.env.NODE_ENV = 'development';
}
module.exports = {
webpack: override(
addLessLoader({
lessLoaderOptions: {
lessOptions: {},
},
}),
addWebpackModuleRule({
test: /\.svg$/,
loader: '@svgr/webpack',
}),
addWebpackPlugin(
new CopyPlugin({
patterns: [
{from: "src/locale/*.json", to: "locale/[name].json"},
],
options: {
concurrency: 100,
},
})
),
addWebpackPlugin(
new ArcoWebpackPlugin({
theme: '@arco-themes/react-arco-pro',
modifyVars: {
'arcoblue-6': setting.themeColor,
},
})
),
addWebpackAlias({
'@': path.resolve(__dirname, 'src'),
}),
addWebpackPlugin(
new webpack.DefinePlugin({
'__GIT_COMMIT': JSON.stringify(commitHash)
})
),
(config) => {
if (process.env.DEV_MODE) {
process.env.NODE_ENV = 'development';
config.mode = 'development';
config.optimization.minimize = false;
}
return config;
},
),
};