From 39040adb45aedad5b225adf0e9f8cf5a3a4d9ed6 Mon Sep 17 00:00:00 2001 From: Shawn Date: Fri, 15 Mar 2019 14:37:51 -0500 Subject: [PATCH] Fix dev mode --- src/platforms/electron/devServer.js | 3 ++- webpack.electron.config.js | 20 ++++++++++++++++---- yarn.lock | 4 ++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/platforms/electron/devServer.js b/src/platforms/electron/devServer.js index 2a9e40c1e..f86b4585e 100644 --- a/src/platforms/electron/devServer.js +++ b/src/platforms/electron/devServer.js @@ -46,6 +46,7 @@ const renderInstance = middleware(renderCompiler, { }); app.use(require('webpack-hot-middleware')(renderCompiler)); app.use(renderInstance); +app.use(express.static('dist/electron/static')); app.listen(8080, () => { console.log(chalk.yellow.bold('Renderer listening on port 8080 (still compiling)')); @@ -64,7 +65,7 @@ mainInstance.waitUntilValid(() => { const electron = require('electron'); const proc = require('child_process'); - const child = proc.spawn(electron, ['./dist/electron/main.js']); + const child = proc.spawn(electron, ['./dist/electron/webpack/main.js']); child.stdout.on('data', (data) => { console.log(data.toString()); diff --git a/webpack.electron.config.js b/webpack.electron.config.js index 5e0c8dac9..f8d50bef2 100644 --- a/webpack.electron.config.js +++ b/webpack.electron.config.js @@ -7,7 +7,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin'); const STATIC_ROOT = path.resolve(__dirname, 'static/'); const DIST_ROOT = path.resolve(__dirname, 'dist/'); -const mainConfig = { +let mainConfig = { target: 'electron-main', entry: { main: './src/platforms/electron/index.js', @@ -46,11 +46,23 @@ const mainConfig = { devServer: { contentBase: path.join(__dirname, 'dist/electron'), }, - externals: { - keytar: 'require("keytar")', - }, }; +if (process.env.NODE_ENV === 'production') { + // Apply prod overrides + mainConfig = merge(mainConfig, { + externals: { + keytar: 'require("keytar")', + }, + }); +} else { + const nodeExternals = require('webpack-node-externals'); + // Apply dev overrides + mainConfig = merge(mainConfig, { + externals: [nodeExternals()], + }); +} + const renderConfig = { target: 'electron-renderer', entry: { diff --git a/yarn.lock b/yarn.lock index afc39b047..c9bff07a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6038,9 +6038,9 @@ lazy-val@^1.0.3, lazy-val@^1.0.4: tar-stream "^1.6.2" zstd-codec "^0.1.1" -lbry-redux@lbryio/lbry-redux#c2c85a49674662724c943c83afb6141bb41019b7: +lbry-redux@lbryio/lbry-redux#2a7e05940f892f104428eeb37bd1f178da811a09: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/c2c85a49674662724c943c83afb6141bb41019b7" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/2a7e05940f892f104428eeb37bd1f178da811a09" dependencies: proxy-polyfill "0.1.6" reselect "^3.0.0" -- 2.45.2