forked from inspirehep/inspirehep-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-overrides.js
36 lines (34 loc) · 1.1 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
const path = require('path');
const { injectBabelPlugin } = require('react-app-rewired');
const SassRuleRewirer = require('react-app-rewire-sass-rule');
const rewireLess = require('react-app-rewire-less');
function rewireSassVariablesToLess(config) {
const sassVariablesToLessRule = {
test: /\.scss$/,
issuer: /\.less$/,
use: {
loader: './scssVariablesToLess.js',
},
};
config.module.rules.push(sassVariablesToLessRule);
return config;
}
module.exports = function override(config, env) {
let overridenConfig = injectBabelPlugin(
['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
config
);
overridenConfig = new SassRuleRewirer()
.withRuleOptions({ issuer: { exclude: /\.less$/ } })
.withLoaderOptions({
data: '@import "variables";',
includePaths: [path.resolve(__dirname, './src')],
})
.rewire(overridenConfig, env);
overridenConfig = rewireSassVariablesToLess(overridenConfig);
overridenConfig = rewireLess.withLoaderOptions({ javascriptEnabled: true })(
overridenConfig,
env
);
return overridenConfig;
};