Skip to content

Commit

Permalink
chore(web): allow reearth_config.json to be set remotely for local de…
Browse files Browse the repository at this point in the history
…velopment (#559)
  • Loading branch information
keiya01 authored Jul 6, 2023
1 parent 1b327bc commit d1cba26
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,27 @@ function config(): Plugin {
return {
name: "reearth-config",
async configureServer(server) {
const envs = loadEnv(
server.config.mode,
server.config.envDir ?? process.cwd(),
server.config.envPrefix,
);
const remoteReearthConfig = envs.REEARTH_WEB_CONFIG_URL
? await (await fetch(envs.REEARTH_WEB_CONFIG_URL)).json()
: {};
const configRes = JSON.stringify(
{
...remoteReearthConfig,
api: "http://localhost:8080/api",
published: "/published.html?alias={}",
// If Cesium version becomes outdated, you can set the Ion token as an environment variables here.
// ex: `CESIUM_ION_ACCESS_TOKEN="ION_TOKEN" yarn start`
// ref: https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/Core/Ion.js#L6-L7
cesiumIonAccessToken: process.env.CESIUM_ION_ACCESS_TOKEN,
...(process.env.CESIUM_ION_ACCESS_TOKEN
? { cesiumIonAccessToken: process.env.CESIUM_ION_ACCESS_TOKEN }
: {}),
...readEnv("REEARTH_WEB", {
source: loadEnv(
server.config.mode,
server.config.envDir ?? process.cwd(),
server.config.envPrefix,
),
source: envs,
}),
...loadJSON("./reearth-config.json"),
},
Expand Down

0 comments on commit d1cba26

Please sign in to comment.