@@ -27,6 +27,14 @@ const RESOLVE_LOCAL_ALIASES = {
27
27
echarts : `${ NODE_MODULES_DIR } /echarts`
28
28
} ;
29
29
30
+ // Add kepler.gl submodule aliases
31
+ const workspaces = WebsitePackage . workspaces ;
32
+ workspaces . forEach ( workspace => {
33
+ // workspace = "./src/types", "./src/constants", etc
34
+ const moduleName = workspace . split ( '/' ) . pop ( ) ;
35
+ RESOLVE_LOCAL_ALIASES [ `@kepler.gl/${ moduleName } ` ] = join ( SRC_DIR , `${ moduleName } /src` ) ;
36
+ } ) ;
37
+
30
38
const config = {
31
39
platform : 'browser' ,
32
40
format : 'iife' ,
@@ -41,7 +49,7 @@ const config = {
41
49
entryPoints : [
42
50
'src/main.js' ,
43
51
] ,
44
- outdir : 'dist' ,
52
+ outfile : 'dist/bundle.js ' ,
45
53
bundle : true ,
46
54
define : {
47
55
NODE_ENV : JSON . stringify ( process . env . NODE_ENV || 'production' ) ,
@@ -74,13 +82,48 @@ function openURL(url) {
74
82
}
75
83
}
76
84
85
+ function logError ( msg ) {
86
+ console . log ( '\x1b[31m%s\x1b[0m' , msg ) ;
87
+ }
88
+
89
+ function logInstruction ( msg ) {
90
+ console . log ( '\x1b[36m%s\x1b[0m' , msg ) ;
91
+ }
92
+
93
+ function validateEnvVariable ( variable , instruction ) {
94
+ if ( ! process . env [ variable ] ) {
95
+ logError ( `Error! ${ variable } is not defined` ) ;
96
+ logInstruction ( `Make sure to run "export ${ variable } =<token>" before deploy the website` ) ;
97
+ logInstruction ( instruction ) ;
98
+ throw new Error ( `Missing ${ variable } ` ) ;
99
+ }
100
+ }
101
+
77
102
( async ( ) => {
78
103
if ( args . includes ( '--build' ) ) {
104
+ // Validate environment variables before production build
105
+ const ENV_VARIABLES_WITH_INSTRUCTIONS = {
106
+ MapboxAccessToken : 'Get your Mapbox token at https://www.mapbox.com/help/how-access-tokens-work/' ,
107
+ DropboxClientId : 'Get your Dropbox key at https://www.dropbox.com/developers' ,
108
+ MapboxExportToken : 'Get your Mapbox token at https://www.mapbox.com/help/how-access-tokens-work/' ,
109
+ CartoClientId : 'Get your CARTO client id' ,
110
+ FoursquareClientId : 'Get your Foursquare client id' ,
111
+ FoursquareDomain : 'Set your Foursquare domain' ,
112
+ FoursquareAPIURL : 'Set your Foursquare API URL' ,
113
+ FoursquareUserMapsURL : 'Set your Foursquare User Maps URL'
114
+ } ;
115
+
116
+ // Validate all environment variables
117
+ Object . entries ( ENV_VARIABLES_WITH_INSTRUCTIONS ) . forEach ( ( [ variable , instruction ] ) => {
118
+ validateEnvVariable ( variable , instruction ) ;
119
+ } ) ;
120
+
79
121
await esbuild
80
122
. build ( {
81
123
...config ,
82
124
minify : true ,
83
- sourcemap : false
125
+ sourcemap : false ,
126
+ alias : RESOLVE_LOCAL_ALIASES
84
127
} )
85
128
. catch ( e => {
86
129
console . error ( e ) ;
0 commit comments