Skip to content

Commit fc654b6

Browse files
committed
Mapbox token as env variable
1 parent 0ce6ee3 commit fc654b6

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/client/configs/portalConfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
}
8484
},
8585
"mapboxConfig": {
86-
"mapboxAccessToken": "pk.eyJ1IjoiZWtrb25lbiIsImEiOiJja2FkbGxiY2owMDZkMnFxcGVqNTZ0dmk2In0.6keLTN8VveJkM5y4_OFmUw",
8786
"mapboxStyle": "light-v10"
8887
},
8988
"yasguiConfig": {

src/client/helpers/helpers.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,13 @@ export const createURIfromLocalID = ({ localID, baseURI, URITemplate }) => {
187187
}
188188

189189
export const processPortalConfig = async portalConfig => {
190-
const { layoutConfig } = portalConfig
190+
const { layoutConfig, mapboxConfig } = portalConfig
191191
const { bannerImage, bannerBackround } = layoutConfig.mainPage
192192
const { default: bannerImageURL } = await import(/* webpackMode: "eager" */ `../img/${bannerImage}`)
193+
const mapboxAccessToken = process.env.MAPBOX_ACCESS_TOKEN
194+
if (mapboxConfig && mapboxAccessToken) {
195+
mapboxConfig.mapboxAccessToken = mapboxAccessToken
196+
}
193197
layoutConfig.mainPage.bannerBackround = bannerBackround.replace('<BANNER_IMAGE_URL', bannerImageURL)
194198
}
195199

webpack.client.common.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require('path')
2+
const dotenv = require('dotenv').config()
23
const HtmlWebpackPlugin = require('html-webpack-plugin')
34
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
45
const webpack = require('webpack')
@@ -27,7 +28,8 @@ module.exports = {
2728
favicon: 'src/client/favicon.ico'
2829
}),
2930
new webpack.DefinePlugin({
30-
'process.env.API_URL': JSON.stringify(apiUrl)
31+
'process.env.API_URL': JSON.stringify(apiUrl),
32+
'process.env': JSON.stringify(dotenv.parsed)
3133
})
3234
],
3335
output: {

0 commit comments

Comments
 (0)