Fix electron-webpack related errors

This commit is contained in:
Igor Gassmann 2017-12-07 09:52:22 -03:00
parent 38daa3d172
commit dbb28dd625
6 changed files with 14 additions and 6 deletions

View file

@ -12,7 +12,8 @@ const kill = require('tree-kill');
const child_process = require('child_process');
const assert = require('assert');
const localVersion = app.getVersion();
export const setMenu = require('./menu/main-menu.js');
const setMenu = require('./menu/main-menu.js');
export const contextMenu = require('./menu/context-menu');
// Debug configs
const isDevelopment = process.env.NODE_ENV === 'development';

View file

@ -203,7 +203,7 @@ lbry.publishDeprecated = function(
};
lbry.imagePath = function(file) {
return __static +"/img/" + file;
return staticResourcesPath + "/img/" + file;
};
lbry.getMediaType = function(contentType, fileName) {

View file

@ -13,9 +13,16 @@ import "scss/all.scss";
const env = process.env.NODE_ENV || "production";
const { remote, ipcRenderer, shell } = require("electron");
const contextMenu = remote.require("./main.js").setMenu;
const contextMenu = remote.require("./main.js").contextMenu;
const app = require("./app");
// Workaround for https://github.com/electron-userland/electron-webpack/issues/52
if (process.env.NODE_ENV !== 'development') {
window.staticResourcesPath = require("path").join(remote.app.getAppPath(), "../static").replace(/\\/g, "\\\\");
} else {
window.staticResourcesPath = "";
}
window.addEventListener("contextmenu", event => {
contextMenu.showContextMenu(
remote.getCurrentWindow(),

View file

@ -22,7 +22,7 @@ class SettingsPage extends React.PureComponent {
});
const success = () => {
this.setState({ clearingCache: false });
window.location.href = `${__static}/index.html`; //TODO: Update this, since index.html isn't anymore
window.location.href = "index.html";
};
const clear = () => this.props.clearCache().then(success.bind(this));

View file

@ -52,7 +52,7 @@ export function doSetClientSetting(key, value) {
export function doGetThemes() {
return function(dispatch, getState) {
const dir = `${__static}/themes`;
const dir = `${staticResourcesPath}/themes`;
readdir(dir, (error, files) => {
if (!error) {

View file

@ -36,5 +36,5 @@ export const selectLanguages = createSelector(
export const selectThemePath = createSelector(
makeSelectClientSetting(settings.THEME),
theme => __static + "/themes/" + (theme || "light") + ".css"
theme => staticResourcesPath + "/themes/" + (theme || "light") + ".css"
);