Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Fix env issues in dev
Browse files Browse the repository at this point in the history
* resolve.alias doesn't work on webpack-dev-server
* Solution is to use DefinePlugin to define the env and if env is undefined, export `.env-dev.js`
  • Loading branch information
dpgraham committed Jun 11, 2018
1 parent b54881e commit fd9dbb8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions app/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let env = {};

// DefinePlugin doesn't work in dev so if _ENV_ is undefined, assume it's a development environment
if (typeof(_ENV_) === "undefined") {
env = require('../env/.env-dev');
} else {
env = _ENV_; // eslint-disable-line no-undef
}

export default env;
2 changes: 1 addition & 1 deletion app/main/auto-updater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import B from 'bluebird';
import { checkUpdate } from './update-checker';
import { getFeedUrl } from './config';
import _ from 'lodash';
import env from 'env';
import env from '../../env';

const isDev = process.env.NODE_ENV === 'development';

Expand Down
3 changes: 3 additions & 0 deletions env/.env-dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {

};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"xpath": "0.0.24"
},
"devDependencies": {
"7zip": "0.0.6",
"appium-fake-driver": "^0.4.0",
"asar": "^0.14.0",
"asyncbox": "^2.3.2",
Expand Down
5 changes: 4 additions & 1 deletion webpack.config.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default {
new webpack.BannerPlugin(
'require("source-map-support").install();',
{ raw: true, entryOnly: false }
)
),
new webpack.DefinePlugin({
_ENV_: process.env.TARGET ? require(`./env/.env-${process.env.TARGET}`) : require('./env/.env')
})
],

target: 'electron-main',
Expand Down

0 comments on commit fd9dbb8

Please sign in to comment.