Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

Enforce checking Mapbox token while building website (#28)

Shan He225c2a7fb31a
diff --git a/README.md b/README.md
index e52e5a70d..38022ee35 100644
--- a/README.md
+++ b/README.md
@@ -32,24 +32,33 @@ then
```
npm start
```
+An Example app will be served at
+http://localhost:8080/
### Website
-In order to start
+Make sure to export mapbox token in the same terminal before start the server.
+```sh
+ export MapboxAccessToken=<insert_your_token>
+```
+In order to start
+```
yarn web
+```
To checkout the build
-
+```
cd website && yarn build
+```
-Publish on github pages
+Publish on github pages.
+<b>important Before publish. Copy the mapbox token at [this link](https://code.uberinternal.com/P101549). Deploy will fail if token is missing<b>
+```
+ export MapboxAccessToken=<insert_your_token>
yarn deploy
-
-
-An Example app will be served at
-http://localhost:8080/
+```
### Basic Usage
You can also take a look at `kepler.gl/examples/demo-app` for how to use kepler.gl in your app
diff --git a/website/README.md b/website/README.md
index b9df28e1b..75b64366a 100644
--- a/website/README.md
+++ b/website/README.md
@@ -2,5 +2,5 @@ This is the source code of the demo website for kepler.gl.
## Developing
- npm install
+ npm install // or yarn --ignore-engies
export MapboxAccessToken=<insert_your_token> && npm start
diff --git a/website/webpack.config.js b/website/webpack.config.js
index 34ae2112e..3f7c65af6 100644
--- a/website/webpack.config.js
+++ b/website/webpack.config.js
@@ -127,6 +127,14 @@ const addProdConfig = config => {
});
};
+function logError(msg) {
+ console.log('\x1b[31m%s\x1b[0m', msg);
+}
+
+function logInstruction(msg) {
+ console.log('\x1b[36m%s\x1b[0m', msg);
+}
+
module.exports = env => {
env = env || {};
@@ -137,11 +145,14 @@ module.exports = env => {
}
if (env.prod) {
+ if (!process.env.MapboxAccessToken) {
+ logError('Error! MapboxAccessToken is not defined');
+ logInstruction(`Make sure to run "export MapboxAccessToken=<token>" before deploy the website`);
+ logInstruction('You can get the token at https://code.uberinternal.com/P101549');
+ throw new Error('Missing Mapbox Access token');
+ }
config = addProdConfig(config);
}
- // Enable to debug config
- // console.warn(JSON.stringify(config, null, 2));
-
return config;
};