-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraco.config.js
55 lines (53 loc) · 1.27 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
const CracoLessPlugin = require('craco-less');
const webpack = require('webpack');
let buildMode = 'local';
if (process.argv.indexOf('dev') > -1) buildMode = 'dev';
if (process.argv.indexOf('prod') > -1) buildMode = 'prod';
if (process.argv.indexOf('stg') > -1) buildMode = 'stg';
const raw = Object.keys(process.env).reduce(
(env, key) => {
env[key] = process.env[key];
return env;
},
{
BUILD_TIME: new Date(),
BUILD_USERNAME: process.env.USERNAME,
BUILD_MODE: buildMode,
}
);
module.exports = {
babel: {
plugins: [
['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
],
},
webpack: {
plugins: [
new webpack.DefinePlugin({
'process.env': Object.keys(raw).reduce((env, key) => {
env[key] = JSON.stringify(raw[key]);
return env;
}, {}),
}),
],
configure: (webpackConfig, { env, paths }) => {
return webpackConfig;
},
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {
'@primary-color': '#17B978',
'@text-selection-bg': '#1890ff',
},
javascriptEnabled: true,
},
},
},
},
],
};