From 9d9976d77af9bd3135ec7c8a16f3974fb6e336b8 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 9 May 2019 00:35:43 -0400 Subject: [PATCH] use port 9090 for webpack since internal-apis uses 8080 --- .eslintrc.json | 3 ++- package.json | 2 +- src/platforms/electron/createWindow.js | 2 +- src/platforms/electron/devServer.js | 15 +++++---------- static/index.dev.html | 2 +- webpack.base.config.js | 6 ++++++ webpack.web.config.js | 3 --- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index ca6035fa1..b6cda7522 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,7 +19,8 @@ "__": true, "__n": true, "app": true, - "IS_WEB": true + "IS_WEB": true, + "WEBPACK_PORT": true }, "rules": { "comma-dangle": ["error", "always-multiline"], diff --git a/package.json b/package.json index af107dd5b..b7173ed15 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "dev": "yarn dev:electron", "dev:electron": "cross-env NODE_ENV=development node ./src/platforms/electron/devServer.js", "dev:web": "cross-env NODE_ENV=development webpack-dev-server --open --hot --progress --config webpack.web.config.js", - "dev:internal-apis": "LBRY_API_URL='http://localhost:9090' yarn dev:electron", + "dev:internal-apis": "LBRY_API_URL='http://localhost:8080' yarn dev:electron", "run:web": "cross-env NODE_ENV=production yarn compile:web && node ./dist/web/server.js", "pack": "electron-builder --dir", "dist": "electron-builder", diff --git a/src/platforms/electron/createWindow.js b/src/platforms/electron/createWindow.js index 79f7ed769..584e6d536 100644 --- a/src/platforms/electron/createWindow.js +++ b/src/platforms/electron/createWindow.js @@ -36,7 +36,7 @@ export default appState => { }; const lbryProto = 'lbry://'; const lbryProtoQ = 'lbry://?'; - const rendererURL = isDev ? `http://localhost:8080` : `file://${__dirname}/index.html`; + const rendererURL = isDev ? `http://localhost:${WEBPACK_PORT}` : `file://${__dirname}/index.html`; let window = new BrowserWindow(windowConfiguration); diff --git a/src/platforms/electron/devServer.js b/src/platforms/electron/devServer.js index a8c16a220..b9d87ae9f 100644 --- a/src/platforms/electron/devServer.js +++ b/src/platforms/electron/devServer.js @@ -1,5 +1,3 @@ -const fs = require('fs'); -const path = require('path'); const chalk = require('chalk'); const webpack = require('webpack'); const merge = require('webpack-merge'); @@ -7,12 +5,9 @@ const middleware = require('webpack-dev-middleware'); const express = require('express'); const app = express(); -// TODO: Spawn separate threads so realtime status logging can be used -// without overwriting information/execptions logged by the compilers -const logRealtime = str => { - let lineCount = (str.match(/\n/) || []).length + 1; - console.log('\u001B[' + lineCount + 'F\u001B[G\u001B[2K' + str); -}; +// Ideally this would come from the same source that sets this port in webpack.web.config.js +// but we can't inject a variable into this file because it is not being touched by webpack +const WEBPACK_PORT = 9090; console.log( chalk.magenta(`Compiling ${chalk.underline('main')} and ${chalk.underline('render')}, this will take a while.`) @@ -46,8 +41,8 @@ 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)')); +app.listen(WEBPACK_PORT, () => { + console.log(chalk.yellow.bold('Renderer listening on port 9090 (still compiling)')); }); mainInstance.waitUntilValid(() => console.log(chalk.green(`${chalk.underline('main')} compilation complete.`))); diff --git a/static/index.dev.html b/static/index.dev.html index a4796bb47..e36d3ec63 100644 --- a/static/index.dev.html +++ b/static/index.dev.html @@ -7,6 +7,6 @@
- + diff --git a/webpack.base.config.js b/webpack.base.config.js index 167716858..4610f096b 100644 --- a/webpack.base.config.js +++ b/webpack.base.config.js @@ -12,6 +12,7 @@ const { ifProduction } = getIfUtils(NODE_ENV); const UI_ROOT = path.resolve(__dirname, 'src/ui/'); const STATIC_ROOT = path.resolve(__dirname, 'static/'); const DIST_ROOT = path.resolve(__dirname, 'dist/'); +const WEBPACK_PORT = 9090; console.log(ifProduction('production', 'development')); @@ -32,6 +33,10 @@ let baseConfig = { node: { __dirname: false, }, + devServer: { + historyApiFallback: true, + port: WEBPACK_PORT, + }, module: { rules: [ { @@ -117,6 +122,7 @@ let baseConfig = { 'process.env.NODE_ENV': JSON.stringify(NODE_ENV), 'process.env.SDK_API_URL': JSON.stringify(process.env.SDK_API_URL), 'process.env.LBRY_API_URL': JSON.stringify(process.env.LBRY_API_URL), + WEBPACK_PORT, }), ], }; diff --git a/webpack.web.config.js b/webpack.web.config.js index 731c4bed8..b0e89c0a7 100644 --- a/webpack.web.config.js +++ b/webpack.web.config.js @@ -18,9 +18,6 @@ const webConfig = { path: __dirname + '/dist/web', publicPath: '/', }, - devServer: { - historyApiFallback: true, - }, module: { rules: [ {