Skip to content

Commit

Permalink
Merge pull request #352 from labzero/jeffrey/remove-browsersync
Browse files Browse the repository at this point in the history
Remove Browsersync
  • Loading branch information
JeffreyATW authored Mar 18, 2024
2 parents e9f71e4 + 1514840 commit 094c14d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 682 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"@types/compression": "^1.7.2",
"@types/connect-flash": "^0.0.37",
"@types/cookie-parser": "^1.4.3",
"@types/cors": "^2.8.17",
"@types/express-serve-static-core": "^4.17.35",
"@types/express-session": "^1.17.6",
"@types/express-sslify": "^1.2.2",
Expand Down Expand Up @@ -118,7 +119,6 @@
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"autoprefixer": "^9.1.5",
"browser-sync": "2.29.1",
"chai": "4.3.7",
"chai-jsdom": "^0.2.3",
"chokidar": "^3.5.3",
Expand Down
4 changes: 2 additions & 2 deletions src/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,11 @@ if (process.env.USE_HTTPS === "true") {
wsServer.listen(config.wsPort, () => {
/* eslint-disable no-console */
console.log(
`The websockets server is running at https://local.lunch.pink:${config.wsPort}/`
`The server is running at https://local.lunch.pink:${config.port}/`
);
});
} else {
wsServer.listen(config.port, () => {
wsServer.listen(config.wsPort, () => {
/* eslint-disable no-console */
console.log(
`The server is running at http://local.lunch.pink:${config.port}/`
Expand Down
40 changes: 21 additions & 19 deletions tools/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

/* eslint-disable no-promise-executor-return */

import fs from "fs";
import path from "path";
import express from "express";
import browserSync from "browser-sync";
import webpack from "webpack";
import webpackDevMiddleware from "webpack-dev-middleware";
import webpackHotMiddleware from "webpack-hot-middleware";
import createLaunchEditorMiddleware from "react-dev-utils/errorOverlayMiddleware";
import http from "http";
import https from "https";
import webpackConfig from "./webpack.config";
import run, { format } from "./run";
import clean from "./clean";
Expand Down Expand Up @@ -164,26 +166,26 @@ async function start() {
appPromiseIsResolved = true;
appPromiseResolve();

// Launch the development server with Browsersync and HMR
await new Promise((resolve, reject) =>
browserSync.create().init(
let httpServer;
if (process.env.USE_HTTPS === "true") {
httpServer = https.createServer(
{
// https://www.browsersync.io/docs/options
ghostMode: false,
host: server.hostname,
https: {
key: path.join(__dirname, "../cert/server.key"),
cert: path.join(__dirname, "../cert/server.crt"),
},
server: "src/server.tsx",
middleware: [server],
open: !process.argv.includes("--silent"),
notify: false,
ui: false,
key: fs.readFileSync(
path.join(__dirname, "../cert/server.key"),
"utf-8"
),
cert: fs.readFileSync(
path.join(__dirname, "../cert/server.crt"),
"utf-8"
),
},
(error, bs) => (error ? reject(error) : resolve(bs))
)
);
server
);
} else {
httpServer = http.createServer(server);
}

httpServer.listen(process.env.PORT || 3000);

const timeEnd = new Date();
const time = timeEnd.getTime() - timeStart.getTime();
Expand Down
Loading

0 comments on commit 094c14d

Please sign in to comment.