-
Notifications
You must be signed in to change notification settings - Fork 12
/
config-overrides.js
46 lines (37 loc) · 1.2 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
const { override, getBabelLoader } = require("customize-cra");
const path = require("path");
const {globSync} = require("glob");
const packageJson = require("./package.json");
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const configureMonaco = (config) => {
config.plugins.push(new MonacoWebpackPlugin({
languages: ['c', 'go', 'python', 'java', 'javascript', 'shell', 'cpp', 'ruby', 'json']
}));
return config;
}
/**
* Allows to include code from other workspaces - the code is then compiled by typescript.
* @param config
* @returns {*}
*/
const addWorkspaces = (config) => {
const loader = getBabelLoader(config, false);
const workspaces = packageJson.workspaces;
let packages;
if ('packages' in workspaces) {
packages = workspaces.packages;
} else {
packages = workspaces;
}
const resolvedPaths = globSync(packages)
.map(p => path.normalize(path.join(process.cwd(), p)));
if (typeof loader.include === 'string') {
loader.include = [loader.include];
}
loader.include = [...loader.include, ...resolvedPaths];
return config;
}
module.exports = override(
addWorkspaces,
configureMonaco
);