-
Notifications
You must be signed in to change notification settings - Fork 3
/
config-overrides.js
66 lines (65 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
const {
override,
fixBabelImports,
addLessLoader,
addWebpackResolve,
addWebpackPlugin,
overrideDevServer,
addWebpackExternals
} = require('customize-cra');
const path = require('path');
const pkgJson = require('./package.json');
const webpack = require('webpack');
const rewireWebpackOutput = require('react-app-rewire-output');
const devServerCustom = () => (config) => {
config.quiet = false;
config.proxy = {
'/api': 'http://localhost:1337'
};
return config;
};
const webpackConfig = () => (config, env) => {
config = rewireWebpackOutput(config, env, {
publicPath: './'
});
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
});
return config;
};
module.exports = {
webpack: override(
fixBabelImports('import', {
libraryName: 'antd-mobile',
libraryDirectory: 'es',
style: true
}),
addWebpackExternals({
moment: 'moment',
lodash: '_'
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: { '@brand-primary': '#01A2A4', '@brand-primary-tap': '#007475' }
}),
webpackConfig(),
addWebpackResolve({
alias: {
'@components': path.resolve(__dirname, 'src/components'),
'@gcomponents': path.resolve(__dirname, 'src/graphql/components'),
'@messages': path.resolve(__dirname, 'src/messages/index')
},
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json', '.html', '.scss', '.less', '.css']
}),
addWebpackPlugin(
new webpack.DefinePlugin({
'process.env': {
version: `"${pkgJson.version}"`
}
})
)
),
devServer: overrideDevServer(devServerCustom())
};