Skip to content

Commit

Permalink
main process can toggle url served based on production or development…
Browse files Browse the repository at this point in the history
… environment
  • Loading branch information
ymekuria committed Nov 2, 2017
1 parent a0718bd commit 48267f2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
8 changes: 8 additions & 0 deletions config/keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
startUrl: process.env.DEV_URL ||
url.format({
pathname: path.join(__dirname, './build/index.html'),
protocol: 'file:',
slashes: true
})
}
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
require('dotenv').config();
const electron = require('electron');
const path = require('path');
const url = require('url');
const MainWindow = require('./app/MainWindow');
const CaptureTray = require('./app/CaptureTray');
const { app, BrowserWIndow, Tray, Menu } = electron;
const startUrl = process.env.DEV_URL;
const startUrl = require('./config/keys').startUrl;

let mainWindow;
let tray;
Expand All @@ -14,9 +16,9 @@ app.on('ready', () => {
{label: 'Record', type: 'radio'},
{label: 'Stop', type: 'radio'},
])
console.log('url', startUrl);
// use the below once a build bundle is created
// mainWindow.loadURL(`file://${__dirname}/public/index.html`);

console.log('env', process.env.NODE_ENV)

mainWindow = new MainWindow(startUrl);

tray = new CaptureTray(iconPath, contextMenu);
Expand Down
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"dependencies": {
"concurrently": "^3.5.0",
"dotenv": "^4.0.0",
"electron": "^1.6.11",
"react": "^15.6.1",
"react-desktop": "^0.3.1",
Expand All @@ -23,6 +24,7 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"electron": "electron .",
"electron-dev": "set DEV_URL=http://localhost:3000 && electron .",
"start": "concurrently \"npm run react-start\" \"wait-on http://localhost:3000/ && npm run electron-dev\""
}
Expand Down

0 comments on commit 48267f2

Please sign in to comment.