forked from ObsidianLabs/SubstrateIDE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
52 lines (47 loc) · 1.56 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
const os = require('os')
const path = require('path')
const webpack = require('webpack')
const {
override,
addWebpackAlias,
addWebpackPlugin
} = require('customize-cra')
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
function findWebpackPlugin (plugins, pluginName) {
return plugins.find(plugin => plugin.constructor.name === pluginName)
}
function overrideProcessEnv (value) {
return config => {
const plugin = findWebpackPlugin(config.plugins, 'DefinePlugin')
const processEnv = plugin.definitions['process.env'] || {}
plugin.definitions['process.env'] = {
...processEnv,
...value
}
return config
}
}
const overrides = [
addWebpackAlias({
'@': path.resolve(__dirname, 'src/lib'),
'@obsidians/welcome': `@obsidians/${process.env.BUILD}-welcome`,
'@obsidians/header': `@obsidians/${process.env.BUILD}-header`,
'@obsidians/project': `@obsidians/${process.env.BUILD}-project`,
'@obsidians/instances': `@obsidians/${process.env.BUILD}-instances`,
'@obsidians/bottombar': `@obsidians/${process.env.BUILD}-bottombar`,
'@obsidians/keypair': `@obsidians/${process.env.BUILD}-keypair`,
}),
overrideProcessEnv({
BUILD: JSON.stringify(process.env.BUILD),
PROJECT_NAME: JSON.stringify(process.env.PROJECT_NAME),
OS_IS_LINUX: JSON.stringify(os.type() === 'Linux'),
}),
]
overrides.push(addWebpackPlugin(
new MonacoWebpackPlugin({
languages: ['json', 'javascript', 'typescript', 'css', 'html', 'markdown', 'c', 'cpp', 'shell']
})
))
module.exports = {
webpack: override(...overrides)
}