OSDN Git Service

Add the production configure for electron
authorZhiting Lin <zlin035@uottawa.ca>
Thu, 22 Mar 2018 03:05:35 +0000 (11:05 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Thu, 22 Mar 2018 03:05:35 +0000 (11:05 +0800)
package.json
src/features/app/components/Container.jsx
src/utility/environment.js
webpack/webpack.app.js

index 00855d4..9005d3e 100644 (file)
@@ -8,9 +8,9 @@
     "postinstall": "npm run build:dll",
     "electron-dev": "DEV_URL=http://localhost:3000  electron --inspect=5858 main.js .",
     "build": "NODE_ENV=production webpack --config webpack/webpack.app.js ",
+    "build-electron": "NODE_ENV=production MODE=electron webpack --config webpack/webpack.app.js ",
     "lint": "eslint \"src/**\"",
     "start": "hjs-dev-server webpack/webpack.app.js --hot --host 0.0.0.0",
-    "start-dev": " npm start && wait-on http://localhost:3000/ && npm run electron-dev",
     "generate-component": "babel-node bin/generate.js component",
     "package:mac": "electron-packager . Bytom --overwrite --platform=darwin --arch=x64 --out=desktop --icon=./static/images/app-icon/mac/app.icns",
     "package:win": "electron-packager . Bytom --overwrite  --platform=win32 --arch=ia32 --out=desktop --icon=./static/images/app-icon/win/app.ico"
index 51d1fde..48e1d56 100644 (file)
@@ -8,6 +8,9 @@ const CORE_POLLING_TIME = 2 * 1000
 class Container extends React.Component {
   constructor(props) {
     super(props)
+    if(props.location.pathname.includes('index.html')){
+      this.props.showRoot()
+    }
     this.redirectRoot = this.redirectRoot.bind(this)
   }
 
index e5edd07..3f46948 100644 (file)
@@ -7,7 +7,7 @@ import { useRouterHistory } from 'react-router'
 import { createHistory } from 'history'
 
 let apiHost, basename
-if (process.env.NODE_ENV === 'production') {
+if ( process.env.NODE_ENV==='production' &&  process.env.MODE!=='electron' ) {
   apiHost = window.location.origin
   basename = '/dashboard'
 } else {
index c2085bd..abc30b4 100644 (file)
@@ -12,7 +12,7 @@ var path = require('path')
 let publicPath = '/'
 let outPath = 'public'
 if (process.env.NODE_ENV === 'production') {
-  publicPath = '/dashboard/'
+  publicPath = ( process.env.MODE === 'electron' )? '' : '/dashboard/'
 } else {
   outPath = 'node_modules/dashboard-dlls'
 }
@@ -111,6 +111,7 @@ config.module.noParse = /node_modules\/json-schema\/lib\/validate\.js/
 config.plugins.push(new webpack.DefinePlugin({
   'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
   'process.env.API_URL': JSON.stringify(process.env.API_URL),
+  'process.env.MODE': JSON.stringify(process.env.MODE),
   'process.env.PROXY_API_HOST': JSON.stringify(process.env.PROXY_API_HOST),
   'process.env.TESTNET_INFO_URL': JSON.stringify(process.env.TESTNET_INFO_URL),
   'process.env.TESTNET_GENERATOR_URL': JSON.stringify(process.env.TESTNET_GENERATOR_URL),