aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2020-04-13 00:56:21 -0700
committerSam Wilkins <samwilkins333@gmail.com>2020-04-13 00:56:21 -0700
commitbf622aa5b5cd9d3256ee8e4f26245b9858cccfba (patch)
treeb4e3c7f8ee9f935cb4edd507e4c6b23015cc1ab3
parente3a5dc3ce59b1d8f2dde63395505061b304d64c0 (diff)
final env cleanup
-rw-r--r--src/client/views/collections/CollectionMapView.tsx20
-rw-r--r--src/server/server_Initialization.ts1
-rw-r--r--webpack.config.js23
3 files changed, 27 insertions, 17 deletions
diff --git a/src/client/views/collections/CollectionMapView.tsx b/src/client/views/collections/CollectionMapView.tsx
index a99d5be50..b67daeb53 100644
--- a/src/client/views/collections/CollectionMapView.tsx
+++ b/src/client/views/collections/CollectionMapView.tsx
@@ -6,6 +6,7 @@ import { Map, Marker, MapProps, GoogleApiWrapper } from "google-maps-react";
import { NumCast, StrCast } from "../../../new_fields/Types";
import { CollectionSubView } from "./CollectionSubView";
import { Utils } from "../../../Utils";
+import { Opt } from "../../../new_fields/Doc";
type MapDocument = makeInterface<[typeof documentSchema]>;
const MapDocument = makeInterface(documentSchema);
@@ -38,8 +39,15 @@ class CollectionMapView extends CollectionSubView<MapDocument, Partial<MapProps>
lat: NumCast(childLayoutPairs[0].layout.locationLat, 0),
lng: NumCast(childLayoutPairs[0].layout.locationLng, 0)
};
- const iconSize = new google.maps.Size(NumCast(layout.mapIconWidth, 45), NumCast(layout.mapIconHeight, 45));
-
+ let icon: Opt<google.maps.Icon>, iconUrl: Opt<string>;
+ if ((iconUrl = StrCast(Document.mapIconUrl, null))) {
+ const iconSize = new google.maps.Size(NumCast(layout.mapIconWidth, 45), NumCast(layout.mapIconHeight, 45));
+ icon = {
+ size: iconSize,
+ scaledSize: iconSize,
+ url: iconUrl
+ };
+ }
return (
<Marker
key={Utils.GenerateGuid()}
@@ -49,11 +57,7 @@ class CollectionMapView extends CollectionSubView<MapDocument, Partial<MapProps>
Document.mapCenterLat = location.lat;
Document.mapCenterLng = location.lng;
}}
- icon={{
- size: iconSize,
- scaledSize: iconSize,
- url: StrCast(Document.mapIconUrl, null)
- }}
+ icon={icon}
/>
);
})}
@@ -64,4 +68,4 @@ class CollectionMapView extends CollectionSubView<MapDocument, Partial<MapProps>
}
-export default GoogleApiWrapper({ apiKey: process.env.GOOGLE_MAPS_API_KEY! })(CollectionMapView) as any; \ No newline at end of file
+export default GoogleApiWrapper({ apiKey: process.env.GOOGLE_MAPS! })(CollectionMapView) as any; \ No newline at end of file
diff --git a/src/server/server_Initialization.ts b/src/server/server_Initialization.ts
index 1150118f7..add607761 100644
--- a/src/server/server_Initialization.ts
+++ b/src/server/server_Initialization.ts
@@ -20,7 +20,6 @@ import * as request from 'request';
import RouteSubscriber from './RouteSubscriber';
import { publicDirectory } from '.';
import { logPort, } from './ActionUtilities';
-import { Utils } from '../Utils';
import { blue, yellow } from 'colors';
import * as cors from "cors";
diff --git a/webpack.config.js b/webpack.config.js
index c8ef269d4..6265883fd 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -16,16 +16,23 @@ const plugins = [
new webpack.HotModuleReplacementPlugin(),
];
-const env = require('dotenv').config().parsed;
-if (env) {
- plugins.push(new webpack.DefinePlugin(Object.keys(env).reduce((prev, next) => {
- if (next.startsWith("DASH_")) {
- prev[`process.env.${next.replace("DASH_", "")}`] = JSON.stringify(env[next]);
- }
- return prev;
- }, {})));
+const dotenv = require('dotenv');
+
+function transferEnvironmentVariables() {
+ const prefix = "_CLIENT_";
+ const env = dotenv.config().parsed;
+ if (env) {
+ plugins.push(new webpack.DefinePlugin(Object.keys(env).reduce((mapping, envKey) => {
+ if (envKey.startsWith(prefix)) {
+ mapping[`process.env.${envKey.replace(prefix, "")}`] = JSON.stringify(env[envKey]);
+ }
+ return mapping;
+ }, {})));
+ }
}
+transferEnvironmentVariables();
+
module.exports = {
mode: 'development',
entry: {