Browse Source

Make build work (at least on Linux)

master
meriadec 7 years ago
parent
commit
ae4edce36c
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 1
      .gitignore
  2. 9
      package.json
  3. 26
      scripts/postbuild.js
  4. 2
      src/globals.js
  5. 4
      src/main/bridge.js
  6. 15
      webpack.renderer.js
  7. 16
      yarn.lock

1
.gitignore

@ -1,4 +1,5 @@
.DS_Store
/static/
/dist/
/node_modules/
/flow-typed/

9
package.json

@ -11,9 +11,9 @@
}
},
"scripts": {
"start": "electron-webpack dev",
"start": "NODE_ENV=development electron-webpack dev",
"compile": "electron-webpack",
"dist": "yarn compile && electron-builder",
"dist": "yarn compile && node scripts/postbuild && electron-builder",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null",
"prettier": "prettier --write \"src/**/*.js\"",
"postinstall": "electron-rebuild && flow-typed install -s",
@ -25,11 +25,14 @@
"webpackConfig": "webpack.renderer.js"
}
},
"resolutions": {
"webpack-sources": "1.0.1"
},
"dependencies": {
"@ledgerhq/hw-app-btc": "^1.0.4",
"@ledgerhq/hw-app-eth": "^1.0.4",
"@ledgerhq/hw-transport": "^1.0.4",
"@ledgerhq/hw-transport-node-hid": "^1.0.4",
"@ledgerhq/hw-transport-node-hid": "^1.0.7",
"babel-loader": "^7.1.2",
"color": "^2.0.1",
"electron-devtools-installer": "^2.2.3",

26
scripts/postbuild.js

@ -0,0 +1,26 @@
const path = require('path')
const fs = require('fs')
function folderExists(p) {
try {
fs.accessSync(p, fs.constants.R_OK | fs.constants.W_OK) // eslint-disable-line no-bitwise
return true
} catch (err) {
return false
}
}
try {
const DEST_FOLDER = path.resolve(__dirname, '../static')
const USB_FILE = path.resolve(__dirname, '../dist/main/usb.js')
const DEST_USB_FILE = path.join(DEST_FOLDER, 'usb.js')
if (!folderExists(DEST_FOLDER)) {
fs.mkdirSync(DEST_FOLDER)
}
const stream = fs.createReadStream(USB_FILE).pipe(fs.createWriteStream(DEST_USB_FILE))
stream.on('error', err => {
throw err
})
} catch (err) {
console.log(`x Something went wrong`, err)
}

2
src/globals.js

@ -2,6 +2,6 @@
const { NODE_ENV } = process.env
global.__ENV__ = NODE_ENV || 'development'
global.__ENV__ = NODE_ENV
global.__DEV__ = global.__ENV__ === 'development'
global.__PROD__ = global.__ENV__ === 'production'

4
src/main/bridge.js

@ -5,13 +5,13 @@ import { ipcMain } from 'electron' // eslint-disable-line import/no-extraneous-d
import { resolve } from 'path'
// $FlowFixMe
import usbBridge from 'file-loader!babel-loader!./usb' // eslint-disable-line import/no-webpack-loader-syntax
import usbBridge from 'file-loader?name=usb.js!babel-loader!./usb' // eslint-disable-line import/no-webpack-loader-syntax
ipcMain.on('msg', (event: any, payload) => {
const { type, data } = payload
const compute = fork(usbBridge, {
cwd: resolve(__dirname, '../../dist/main'),
cwd: resolve(__dirname, __DEV__ ? '../../dist/main' : '../static'),
})
compute.send({ type, data })

15
webpack.renderer.js

@ -2,10 +2,7 @@ const webpack = require('webpack')
require('./src/globals')
module.exports = {
output: {
publicPath: '/',
},
const config = {
plugins: [
new webpack.DefinePlugin({
__DEV__,
@ -16,3 +13,13 @@ module.exports = {
historyApiFallback: true,
},
}
if (__DEV__) {
Object.assign(config, {
output: {
publicPath: '/',
},
})
}
module.exports = config

16
yarn.lock

@ -90,9 +90,9 @@
dependencies:
"@ledgerhq/hw-transport" "^1.0.5"
"@ledgerhq/hw-transport-node-hid@^1.0.4":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-1.0.5.tgz#2f35773ece17d856a42868fd2d9497c6a7ed20dc"
"@ledgerhq/hw-transport-node-hid@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-node-hid/-/hw-transport-node-hid-1.0.7.tgz#93aa2d0ce868eb469c9a0f095c46f5b2a27bdce4"
dependencies:
"@ledgerhq/hw-transport" "^1.0.5"
node-hid "^0.7.2"
@ -6849,7 +6849,7 @@ source-map@0.5.6:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412"
source-map@0.5.x, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1:
source-map@0.5.x, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1, source-map@~0.5.3:
version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
@ -7641,12 +7641,12 @@ webpack-merge@^4.1.0:
dependencies:
lodash "^4.17.4"
webpack-sources@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54"
webpack-sources@1.0.1, webpack-sources@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf"
dependencies:
source-list-map "^2.0.0"
source-map "~0.6.1"
source-map "~0.5.3"
webpack@^3.10.0:
version "3.10.0"

Loading…
Cancel
Save