forked from jamaljsr/polar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rescriptsrc.js
91 lines (87 loc) · 2.38 KB
/
.rescriptsrc.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
80
81
82
83
84
85
86
87
88
89
90
91
const darkThemeVars = require('antd/dist/dark-theme');
const getLessLoader = (test, withModules) => {
return {
test,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: !withModules
? undefined
: {
sourceMap: true,
modules: true,
localIdentName: '[local]___[hash:base64:5]',
},
},
{
loader: 'less-loader',
options: {
javascriptEnabled: true,
modifyVars: {
hack: `true;@import "${require.resolve(
'antd/lib/style/color/colorPalette.less',
)}";`,
...darkThemeVars,
'@primary-color': '#d46b08',
},
},
},
],
};
};
module.exports = [
config => {
// set target on webpack config to support electron
config.target = 'electron-renderer';
// add support for hot reload of hooks
config.resolve.alias['react-dom'] = '@hot-loader/react-dom';
return config;
},
[
'use-babel-config',
{
presets: ['react-app'],
plugins: [
// add babel-plugin-import for antd
[
'import',
{
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
},
],
// babel optimizations for emotion styles
[
'emotion',
{
// sourceMap is on by default but source maps are dead code eliminated in production
sourceMap: true,
autoLabel: true,
labelFormat: 'x-[local]',
cssPropOptimization: true,
},
],
// adds support for live hot reload
'react-hot-loader/babel',
],
},
],
// add less-loader for antd
config => {
const rule = config.module.rules.find(rule => rule.oneOf);
rule.oneOf.unshift(getLessLoader(/\.less$/, false));
rule.oneOf.unshift(getLessLoader(/\.module\.less$/, true));
return config;
},
config => {
// helper function to troubleshoot webpack config issues
RegExp.prototype.toJSON = RegExp.prototype.toString;
Function.prototype.toJSON = () => 'function() { }'; // Function.prototype.toString;
// uncomment the line below to log the webpack config to the console
// console.log(JSON.stringify(config.module.rules, null, 2));
// process.exit(1);
return config;
},
];