fix(credentials): Pass credentials through DefinePlugin

This commit is contained in:
Stuart Taylor
2018-03-09 15:59:45 +00:00
parent a0c3d5bd08
commit fa59bcfd7b
4 changed files with 12 additions and 14 deletions

View File

@ -1,3 +1,4 @@
/* global __OPBEAT__ORG_ID __OPBEAT__APP_ID */
import initOpbeat from 'opbeat-react'; import initOpbeat from 'opbeat-react';
import { createOpbeatMiddleware } from 'opbeat-react/redux'; import { createOpbeatMiddleware } from 'opbeat-react/redux';
import Rx from 'rx'; import Rx from 'rx';
@ -19,19 +20,16 @@ import {
saveToColdStorage saveToColdStorage
} from './cold-reload'; } from './cold-reload';
import opBeat from '../opbeat-config';
const localhostRE = /^(localhost|127.|0.)/; const localhostRE = /^(localhost|127.|0.)/;
const enableOpbeat = !localhostRE.test(window.location.hostname); const enableOpbeat = !localhostRE.test(window.location.hostname);
if (enableOpbeat && opBeat) { if (enableOpbeat) {
const { orgId, appId } = opBeat; if (!__OPBEAT__ORG_ID || !__OPBEAT__APP_ID) {
if (!orgId || !appId) { console.error('OpBeat credentials not found in .env');
console.error('OpBeat credentials not found in ~/opbeat-config');
} }
initOpbeat({ initOpbeat({
orgId, orgId: __OPBEAT__ORG_ID,
appId appId: __OPBEAT__APP_ID
}); });
} }

View File

@ -1,5 +0,0 @@
export default {
// replace these values with your app specific credentials
orgId: '',
appId: ''
};

View File

@ -1,5 +1,8 @@
MONGOHQ_URL='mongodb://localhost:27017/freecodecamp' MONGOHQ_URL='mongodb://localhost:27017/freecodecamp'
OPBEAT_FRONTEND_ORG_ID=stuff
OPBEAT_FRONTEND_APP_ID=stuff
FACEBOOK_ID=stuff FACEBOOK_ID=stuff
FACEBOOK_SECRET=stuff FACEBOOK_SECRET=stuff

View File

@ -55,7 +55,9 @@ module.exports = {
'process.env': { 'process.env': {
NODE_ENV: JSON.stringify(__DEV__ ? 'development' : 'production') NODE_ENV: JSON.stringify(__DEV__ ? 'development' : 'production')
}, },
__DEVTOOLS__: !__DEV__ __DEVTOOLS__: !__DEV__,
__OPBEAT__ORG_ID: JSON.stringify(process.env.OPBEAT_FRONTEND_ORG_ID),
__OPBEAT__APP_ID: JSON.stringify(process.env.OPBEAT_FRONTEND_APP_ID)
}), }),
// Use browser version of visionmedia-debug // Use browser version of visionmedia-debug
new webpack.NormalModuleReplacementPlugin( new webpack.NormalModuleReplacementPlugin(