-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
147 lines (144 loc) · 5.67 KB
/
next.config.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
const fs = require('fs').promises
const path = require('path')
// default configs
const defaults = {
CANONICAL_URL : 'http://localhost:3000',
COMPILER_URL : 'https://strawbees-compiler-stage.us-east-1.elasticbeanstalk.com',
STRAWBEES_CODE_API_URL : 'http://localhost:1337',
LOCALES : ['en', 'pt_BR', 'sv', 'zh-Hans-CN', 'ja'],
ROOT_PATH : '',
SHARE_LINKS_OMIT_ROOT_PATH : true,
USE_SERVICE_WORKER : false,
PREFER_WEB_SERIAL : true,
ENABLE_SIMULATOR : true,
URL_SCHEME : 'strawbeescode',
GAID : 'UA-NNNNNN-N',
CHROME_EXTENSION_ID : 'ackaalhbfjagidmjlhlokoblhbnahegd',
WINDOWS_DRIVERS_INSTALLER_URL : 'https://github.com/strawbees/quirkbot-driver/releases/download/v2.0.0.0/Quirkbot-Windows-Drivers-Installer-v2.0.0.0.exe',
DOWNLOAD_DESKTOP_APP_URL : 'https://downloads.strawbees.com/code-desktop',
NEXT_SERVER_PORT : 3000,
NEXT_EXPORT_PATH : path.resolve(__dirname, 'out'),
QUIRKBOT_USB_SERIAL_IDS : [
{ usbVendorId : 0x2886, usbProductId : 0xF004 },
{ usbVendorId : 0x2886, usbProductId : 0xF005, isBootloader : true },
{ usbVendorId : 0x2886, usbProductId : 0xF006, isBootloader : true },
{ usbVendorId : 0x2886, usbProductId : 0xF007, isBootloader : true },
],
}
// configs for common known targets
const commonConfigs = {
web_stage : {
CANONICAL_URL : 'https://code-stage.strawbees.com',
COMPILER_URL : 'https://strawbees-compiler-stage.us-east-1.elasticbeanstalk.com',
STRAWBEES_CODE_API_URL : 'https://cloud-api-stage.strawbees.com',
LOCALES : ['en', 'pt_BR', 'sv', 'zh-Hans-CN', 'ja'],
ROOT_PATH : '',
USE_SERVICE_WORKER : true,
PREFER_WEB_SERIAL : false,
ENABLE_SIMULATOR : true,
URL_SCHEME : 'strawbeescode-stage',
GAID : 'UA-69443341-7',
CHROME_EXTENSION_ID : 'ackaalhbfjagidmjlhlokoblhbnahegd',
DOWNLOAD_DESKTOP_APP_URL : 'https://strawbees-downloads-stage.s3.amazonaws.com/code-desktop',
},
web_production : {
CANONICAL_URL : 'https://code.strawbees.com',
COMPILER_URL : 'https://strawbees-compiler.us-east-1.elasticbeanstalk.com',
STRAWBEES_CODE_API_URL : 'https://cloud-api.strawbees.com',
LOCALES : ['en', 'pt_BR', 'sv', 'zh-Hans-CN', 'ja'],
ROOT_PATH : '',
USE_SERVICE_WORKER : true,
PREFER_WEB_SERIAL : false,
ENABLE_SIMULATOR : false,
URL_SCHEME : 'strawbeescode',
GAID : 'UA-69443341-8',
CHROME_EXTENSION_ID : 'ackaalhbfjagidmjlhlokoblhbnahegd',
DOWNLOAD_DESKTOP_APP_URL : 'https://downloads.strawbees.com/code-desktop',
},
desktop_stage : {
CANONICAL_URL : 'https://code-stage.strawbees.com',
COMPILER_URL : 'http://localhost:9511',
STRAWBEES_CODE_API_URL : 'https://cloud-api-stage.strawbees.com',
LOCALES : ['en', 'pt_BR', 'sv', 'zh-Hans-CN', 'ja'],
ROOT_PATH : '/ui',
USE_SERVICE_WORKER : false,
PREFER_WEB_SERIAL : true,
ENABLE_SIMULATOR : true,
URL_SCHEME : 'strawbeescode-stage',
GAID : 'UA-69443341-7',
CHROME_EXTENSION_ID : 'jgbaejhmonchgianepimdbcpfgcbdmam',
DOWNLOAD_DESKTOP_APP_URL : 'https://strawbees-downloads-stage.s3.amazonaws.com/code-desktop',
},
desktop_production : {
CANONICAL_URL : 'https://code.strawbees.com',
COMPILER_URL : 'http://localhost:9511',
STRAWBEES_CODE_API_URL : 'https://cloud-api.strawbees.com',
LOCALES : ['en', 'pt_BR', 'sv', 'zh-Hans-CN', 'ja'],
ROOT_PATH : '/ui',
USE_SERVICE_WORKER : false,
PREFER_WEB_SERIAL : false,
ENABLE_SIMULATOR : false,
URL_SCHEME : 'strawbeescode',
GAID : 'UA-69443341-8',
CHROME_EXTENSION_ID : 'jgbaejhmonchgianepimdbcpfgcbdmam',
DOWNLOAD_DESKTOP_APP_URL : 'https://downloads.strawbees.com/code-desktop',
},
}
// generate the final config, allowing overwritting from env
const config = {
CONFIG : process.env.CONFIG || 'default',
...defaults,
...(process.env.CONFIG ? commonConfigs[process.env.CONFIG] : {}),
...(Object.keys(defaults).reduce((acc, key) => {
if (typeof process.env[key] !== 'undefined') {
acc[key] = process.env[key]
}
return acc
}, {})),
}
module.exports = {
useFileSystemPublicRoutes : false,
publicRuntimeConfig : config,
assetPrefix : config.ROOT_PATH,
trailingSlash : true,
exportPathMap : async () => JSON.parse(await fs.readFile(path.resolve(__dirname, 'static', 'routes.json'))),
webpack : (webpackConfig) => {
/**
* mock fs, needed for the tree-sitter module
*/
webpackConfig.node = { fs : 'empty' }
/**
* svg loader
*/
// first remove any existing rules for svg
const fileLoaderRule = webpackConfig.module.rules.find(rule => rule.test && rule.test.test('.svg'))
if (fileLoaderRule) {
fileLoaderRule.exclude = /\.svg$/
}
// then add the @svgr rule
webpackConfig.module.rules.push({
test : /\.svg$/,
use : [{
loader : '@svgr/webpack',
options : {
svgoConfig : {
plugins : {
removeViewBox : false,
},
},
},
}],
})
/**
* aliases
*/
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
root : path.resolve(__dirname),
data : path.resolve(__dirname, 'data'),
static : path.resolve(__dirname, 'static'),
src : path.resolve(__dirname, 'src'),
}
return webpackConfig
},
}