-
Notifications
You must be signed in to change notification settings - Fork 9
/
override.js
27 lines (20 loc) · 993 Bytes
/
override.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
const path = require('path');
const glob = require('glob');
const findLoader = require(path.join(__dirname, 'findLoader'));
const lernaRoot = require(path.join(__dirname, 'getLernaRoot'))();
const lernaPackageJson = require(path.join(lernaRoot, 'package.json'));
module.exports = (configDir, configFile) => {
const reactAppSrcDir = path.join(configDir, '..', '..','..', 'src');
const backupConfig = path.join(configDir, `backup.${path.parse(configFile).base}`);
const settings = lernaPackageJson['babel-loader-lerna-cra'];
const appsGlob = path.join(lernaRoot, settings.apps);
const importsGlob = path.join(lernaRoot, settings.imports);
const config = {
apps: glob.sync(appsGlob),
imports: glob.sync(importsGlob)
};
const webpackConfig = require(backupConfig);
const loaderToOverride = findLoader(webpackConfig, reactAppSrcDir);
loaderToOverride.include = [...config.imports, reactAppSrcDir];
return webpackConfig;
};