Closed kylebarron closed 4 years ago
Thanks for the issue. If you're cloning the source from Github you need to create and fill out a config.js
file that's in the src
directory. This contains your Mapbox token. There is a config.template.js
file that has the structure, but you need to make your own config.js. And I need to document it!
{*/src/config.js*}
export default {
mapboxToken: 'your token'
};
This shouldn't happen if you pulled the published versions from NPM because it's the dev Storybook code that's triggering this. Open to ideas for better mechanics here, or do you think better documentation is all that's needed?
Followup: I'm reading over how some other libraries approach mapbox tokens. For example: https://uber.github.io/react-map-gl/#/Documentation/getting-started/about-mapbox-tokens
I thought about using dotenv, but opted for a config file that isn't tracked in git instead.
Added documentation in #5. Closing. Will revisit if people have better ideas on how to handle this.
It looks like the install from npm is working now.
Also, I've seen one or two repositories that have like a default config.js
with an empty token, so that the errors when building the project aren't as obscure, and the project builds. But then there's a warning in the terminal if the token isn't valid.
From my perspective, including an empty config.js
file would increase the likelihood of accidentally exposing a Mapbox token.
We need a token during development when running Storybook, so during dev config.js
needs a real token. Right now, we exclude config.js
from version control so a token won't accidentally make it to Github. If it was in version control, developers would need to remove their token before any commits, or absolutely make sure not to commit changes to config.js. I think the added step of having them modify the config.template.js
to config.js
is worth the additional security over trying to catch accidental commits.
A better warning would be good though. I will think on ways to improve that.
Yeah, good points. I go the dotenv route in my projects, and just raise an error if the MapboxToken env variable isn't set.
Describe the bug
All of
yarn
,yarn dev
,yarn add @cartolab/elements
fail.To Reproduce
Expected behavior
Project builds
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Traceback: