Fix electron-webpack related errors

This commit is contained in:
Igor Gassmann 2017-12-06 13:32:21 -03:00
parent b83679fa4a
commit b07e16c913
13 changed files with 27 additions and 156 deletions

View file

@ -132,7 +132,6 @@
"devtron": "^1.4.0",
"electron": "^1.7.9",
"electron-builder": "^19.47.1",
"electron-debug": "^1.4.0",
"electron-devtools-installer": "^2.2.1",
"electron-webpack": "^1.11.0",
"husky": "^0.13.4",
@ -143,7 +142,6 @@
"node-sass": "^4.7.2",
"prettier": "^1.4.2",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.0",
"webpack": "^3.10.0",
"webpack-build-notifier": "^0.1.18"
},

View file

@ -12,15 +12,13 @@ const kill = require('tree-kill');
const child_process = require('child_process');
const assert = require('assert');
const localVersion = app.getVersion();
const setMenu = require('./menu/main-menu.js');
export const setMenu = require('./menu/main-menu.js');
// Debug configs
const isDebug = process.env.NODE_ENV === 'development';
if (isDebug) {
const isDevelopment = process.env.NODE_ENV === 'development';
if (isDevelopment) {
try
{
require('electron-debug')({showDevTools: true});
const { default: installExtension, REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } = require('electron-devtools-installer');
app.on('ready', () => {
[REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS].forEach(extension => {
@ -30,7 +28,7 @@ if (isDebug) {
});
});
}
catch (err) // electron-debug is in devDependencies, but some
catch (err)
{
console.error(err)
}
@ -39,9 +37,9 @@ if (isDebug) {
// Misc constants
const LATEST_RELEASE_API_URL = 'https://api.github.com/repos/lbryio/lbry-app/releases/latest';
const DAEMON_PATH = process.env.LBRY_DAEMON || path.join(__static, 'daemon/lbrynet-daemon');
const rendererUrl = isDebug
const rendererUrl = isDevelopment
? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`
: `file://${__dirname}/index.html`
: `file://${__dirname}/index.html`;
let client = jayson.client.http({
host: 'localhost',
@ -131,10 +129,13 @@ function getPidsForProcessName(name) {
}
function createWindow () {
win = new BrowserWindow({backgroundColor: '#155B4A', minWidth: 800, minHeight: 600 }) //$color-primary
// Disable renderer process's webSecurity on development to enable CORS.
win = isDevelopment
? new BrowserWindow({backgroundColor: '#155B4A', minWidth: 800, minHeight: 600, webPreferences: {webSecurity: false}})
: new BrowserWindow({backgroundColor: '#155B4A', minWidth: 800, minHeight: 600});
win.maximize()
if (isDebug) {
if (isDevelopment) {
win.webContents.openDevTools();
}
win.loadURL(rendererUrl)
@ -187,7 +188,7 @@ function createWindow () {
// Menu bar
win.setAutoHideMenuBar(true);
win.setMenuBarVisibility(isDebug);
win.setMenuBarVisibility(isDevelopment);
setMenu();
};

View file

@ -1,7 +1,7 @@
import store from "store.js";
import { remote } from "electron";
const env = ENV;
const env = process.env.NODE_ENV || "production";
const config = {
...require(`./config/${env}`),
};

View file

@ -21,6 +21,8 @@ jsonrpc.call = function(
error = new Error("Protocol error with unknown response signature");
}
return Promise.reject(error);
}).catch(e => {
console.log(e);
});
}
}

View file

@ -11,7 +11,6 @@ function setLocal(key, value) {
}
const { remote, ipcRenderer } = require("electron");
const menu = remote.require("./menu/main-menu");
let lbry = {
isConnected: false,
@ -204,7 +203,7 @@ lbry.publishDeprecated = function(
};
lbry.imagePath = function(file) {
return __static + "img/" + file;
return "img/" + file;
};
lbry.getMediaType = function(contentType, fileName) {

View file

@ -9,10 +9,11 @@ import { doDaemonReady } from "redux/actions/app";
import { doNavigate } from "redux/actions/navigation";
import { doDownloadLanguages } from "redux/actions/settings";
import * as types from "constants/action_types";
import "scss/all.scss";
const env = ENV;
const env = process.env.NODE_ENV || "production";
const { remote, ipcRenderer, shell } = require("electron");
const contextMenu = remote.require("./menu/context-menu");
const contextMenu = remote.require("./main.js").setMenu;
const app = require("./app");
window.addEventListener("contextmenu", event => {
@ -76,7 +77,7 @@ var init = function() {
<SnackBar />
</div>
</Provider>,
app
document.getElementById('app')
);
}
@ -87,7 +88,7 @@ var init = function() {
<Provider store={store}>
<SplashScreen onReadyToLaunch={onDaemonReady} />
</Provider>,
app
document.getElementById('app')
);
}
};

View file

@ -63,7 +63,7 @@ body
&:before {
$width: 30px;
position: absolute;
background: url(__static + '../img/busy.gif') no-repeat center center;
background: url('../../../static/img/busy.gif') no-repeat center center;
width: $width;
height: $spacing-vertical;
content: "";
@ -129,7 +129,7 @@ p
.busy-indicator
{
background: url(__static + '/img/busy.gif') no-repeat center center;
background: url('../../../static/img/busy.gif') no-repeat center center;
display: inline-block;
margin: -1em 0;
min-width: 16px;

View file

@ -1,7 +1,7 @@
@font-face {
font-family: 'FontAwesome';
src: url(__static + '/font/fontawesome-webfont.eot?v=4.7.0');
src: url(__static + '/font/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url(__static + '/font/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url(__static + '/font/fontawesome-webfont.woff?v=4.7.0') format('woff'), url(__static + '/font/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url(__static + '/font/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
src: url('../../../static/font/fontawesome-webfont.eot?v=4.7.0');
src: url('../../../static/font/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('../../../static/font/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('../../../static/font/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('../../../static/font/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('../../../static/font/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}

View file

@ -20,7 +20,7 @@ import createFilter from "redux-persist-transform-filter";
const localForage = require("localforage");
const redux = require("redux");
const thunk = require("redux-thunk").default;
const env = ENV;
const env = process.env.NODE_ENV || "production";
function isFunction(object) {
return typeof object === "function";

View file

@ -1,11 +0,0 @@
@echo off
set found=
for %%F in (
"%~dp0\node_modules\node-sass\bin\node-sass"
"%~dp0\node_modules\.bin\webpack"
) do if exist %%F (set found=1)
if not defined found EXIT
node %~dp0\node_modules\node-sass\bin\node-sass --output %~dp0\dist\css --sourcemap=none %~dp0\src\renderer\scss
%~dp0\node_modules\.bin\webpack --config %~dp0\src\renderer\webpack.dev.js --progress --colors --watch

View file

@ -1,25 +0,0 @@
#!/bin/bash
set -euo pipefail
#set -x
#trap 'kill $(jobs -p)' EXIT # IS THIS NECESSARY? on linux, it kills all child processes when you ctrl-c
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
(
cd "$DIR"
mkdir -p $DIR/dist/css
mkdir -p $DIR/dist/js
if [ ! -d "$DIR/node_modules" ]; then
echo "Installing NPM modules"
yarn install
fi
# run sass once without --watch to force update. then run with --watch to keep watching
node_modules/.bin/node-sass --output $DIR/dist/css --sourcemap=none $DIR/src/renderer/scss/
node_modules/.bin/node-sass --output $DIR/dist/css --sourcemap=none --watch $DIR/src/renderer/scss/ &
node_modules/.bin/webpack --config $DIR/src/renderer/webpack.dev.js --progress --colors --watch
)

View file

@ -17,7 +17,6 @@ module.exports = {
},
// This allows imports to be made from the renderer process root (https://moduscreate.com/blog/es6-es2015-import-no-relative-path-webpack/).
resolve: {
descriptionFiles: ["package.json"],
modules: [ELECTRON_RENDERER_PROCESS_ROOT, 'node_modules', __dirname],
extensions: ['.js', '.jsx', '.scss']
}

View file

@ -1908,22 +1908,6 @@ concat-stream@1.6.0, concat-stream@^1.5.0, concat-stream@^1.5.2:
readable-stream "^2.2.2"
typedarray "^0.0.6"
concordance@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/concordance/-/concordance-2.0.0.tgz#c3c5dbffa83c29537df202bded8fa1d6aa94e805"
dependencies:
esutils "^2.0.2"
fast-diff "^1.1.1"
function-name-support "^0.2.0"
js-string-escape "^1.0.1"
lodash.clonedeep "^4.5.0"
lodash.flattendeep "^4.4.0"
lodash.merge "^4.6.0"
md5-hex "^2.0.0"
moment "^2.18.1"
semver "^5.3.0"
well-known-symbols "^1.0.0"
config-chain@~1.1.11:
version "1.1.11"
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.11.tgz#aba09747dfbe4c3e70e766a6e41586e1859fc6f2"
@ -2557,13 +2541,6 @@ electron-builder@^19.47.1:
update-notifier "^2.3.0"
yargs "^10.0.3"
electron-debug@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/electron-debug/-/electron-debug-1.4.0.tgz#bec7005522220a9d0622153352e1bbff0f37af2e"
dependencies:
electron-is-dev "^0.3.0"
electron-localshortcut "^3.0.0"
electron-devtools-installer@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/electron-devtools-installer/-/electron-devtools-installer-2.2.1.tgz#0beb73ccbf65cbc4d09e706cebda638f839b8c55"
@ -2609,24 +2586,6 @@ electron-download@^3.0.1:
semver "^5.3.0"
sumchecker "^1.2.0"
electron-is-accelerator@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz#509e510c26a56b55e17f863a4b04e111846ab27b"
electron-is-dev@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-0.3.0.tgz#14e6fda5c68e9e4ecbeff9ccf037cbd7c05c5afe"
electron-localshortcut@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/electron-localshortcut/-/electron-localshortcut-3.0.1.tgz#cefc1bdbe897defc2e6d9c62c657353cfaefcb91"
dependencies:
debug "^2.6.8"
electron-is-accelerator "^0.1.0"
insp "^0.1.0"
keyboardevent-from-electron-accelerator "^0.7.0"
keyboardevents-areequal "^0.2.1"
electron-osx-sign@0.4.7:
version "0.4.7"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.7.tgz#1d75647a82748eacd48bea70616ec83ffade3ee5"
@ -3117,10 +3076,6 @@ fast-deep-equal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff"
fast-diff@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.1.tgz#0aea0e4e605b6a2189f0e936d4b7fbaf1b7cfd9b"
fast-json-stable-stringify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
@ -3398,10 +3353,6 @@ function-bind@^1.0.2, function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
function-name-support@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/function-name-support/-/function-name-support-0.2.0.tgz#55d3bfaa6eafd505a50f9bc81fdf57564a0bb071"
gauge@~2.7.3:
version "2.7.4"
resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
@ -3979,12 +3930,6 @@ inline-process-browser@^1.0.0:
falafel "^1.0.1"
through2 "^0.6.5"
insp@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/insp/-/insp-0.1.0.tgz#1a532c78664745dbb1d2c08e39f8d4832ab26349"
dependencies:
concordance "^2.0.0"
install@^0.8.7:
version "0.8.9"
resolved "https://registry.yarnpkg.com/install/-/install-0.8.9.tgz#9f4b5c0d1851ef872e9df85e4f7162d4e5dcdbed"
@ -4293,10 +4238,6 @@ js-base64@^2.1.9:
version "2.3.2"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.3.2.tgz#a79a923666372b580f8e27f51845c6f7e8fbfbaf"
js-string-escape@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef"
js-tokens@^3.0.0, js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
@ -4420,14 +4361,6 @@ jstransform@~3.0.0:
esprima-fb "~3001.1.0-dev-harmony-fb"
source-map "0.1.31"
keyboardevent-from-electron-accelerator@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/keyboardevent-from-electron-accelerator/-/keyboardevent-from-electron-accelerator-0.7.0.tgz#0532545ac08ce2dd1bacd81f2a8a9c67abee7a1a"
keyboardevents-areequal@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/keyboardevents-areequal/-/keyboardevents-areequal-0.2.1.tgz#4431d04fecc44f364cda73cf3f3270e177a54b8c"
keypress@0.1.x:
version "0.1.0"
resolved "https://registry.yarnpkg.com/keypress/-/keypress-0.1.0.tgz#4a3188d4291b66b4f65edb99f806aa9ae293592a"
@ -4665,14 +4598,10 @@ lodash.chunk@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.chunk/-/lodash.chunk-4.2.0.tgz#66e5ce1f76ed27b4303d8c6512e8d1216e8106bc"
lodash.clonedeep@^4.3.2, lodash.clonedeep@^4.5.0, lodash.clonedeep@~4.5.0:
lodash.clonedeep@^4.3.2, lodash.clonedeep@~4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
lodash.flattendeep@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"
lodash.forin@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.forin/-/lodash.forin-4.4.0.tgz#5d3f20ae564011fbe88381f7d98949c9c9519731"
@ -4693,10 +4622,6 @@ lodash.memoize@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
lodash.merge@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5"
lodash.mergewith@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz#150cf0a16791f5903b8891eab154609274bdea55"
@ -4840,16 +4765,6 @@ math-expression-evaluator@^1.2.14:
version "1.2.17"
resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz#de819fdbcd84dccd8fae59c6aeb79615b9d266ac"
md5-hex@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-2.0.0.tgz#d0588e9f1c74954492ecd24ac0ac6ce997d92e33"
dependencies:
md5-o-matic "^0.1.1"
md5-o-matic@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/md5-o-matic/-/md5-o-matic-0.1.1.tgz#822bccd65e117c514fab176b25945d54100a03c3"
md5.js@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.4.tgz#e9bdbde94a20a5ac18b04340fc5764d5b09d901d"
@ -5050,10 +4965,6 @@ modify-filename@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/modify-filename/-/modify-filename-1.1.0.tgz#9a2dec83806fbb2d975f22beec859ca26b393aa1"
moment@^2.18.1:
version "2.18.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f"
move-concurrently@^1.0.1, move-concurrently@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
@ -8193,10 +8104,6 @@ websocket-extensions@>=0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29"
well-known-symbols@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/well-known-symbols/-/well-known-symbols-1.0.0.tgz#73c78ae81a7726a8fa598e2880801c8b16225518"
whatwg-fetch@>=0.10.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"