mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-16 05:07:55 +08:00
* update to webpack 5 * update babel * update eslint * update cheerio * update npm min to v7 * revert engine change * generate package lock with npm v6 (lockfileVersion 1) * add region to test setup * update blueprint popover2 * tabindex changes due to blueprint popover2 revision * update snapshots * update lodash and pako * fix typo * fix lodash refactoring * more lodash refactoring * update babel and blueprintjs * update jest support packages * update puppeteer * update regl * update react-icons and react-helmet * update react and react-dom
68 lines
1.5 KiB
JavaScript
68 lines
1.5 KiB
JavaScript
const chalk = require("chalk");
|
|
const express = require("express");
|
|
const favicon = require("serve-favicon");
|
|
const webpack = require("webpack");
|
|
const devMiddleware = require("webpack-dev-middleware");
|
|
const config = require("../configuration/webpack/webpack.config.dev");
|
|
const utils = require("./utils");
|
|
|
|
process.env.NODE_ENV = "development";
|
|
|
|
const CLIENT_PORT = process.env.CXG_CLIENT_PORT;
|
|
const { CXG_SERVER_PORT } = process.env;
|
|
|
|
const API = {
|
|
prefix: `http://localhost:${CXG_SERVER_PORT}/`,
|
|
};
|
|
|
|
// Set up compiler
|
|
const compiler = webpack(config);
|
|
|
|
compiler.hooks.invalid.tap("invalid", () => {
|
|
utils.clearConsole();
|
|
console.log("Compiling...");
|
|
});
|
|
|
|
compiler.hooks.done.tap("done", (stats) => {
|
|
utils.formatStats(stats, CLIENT_PORT);
|
|
});
|
|
|
|
// Launch server
|
|
const app = express();
|
|
|
|
app.use(
|
|
devMiddleware(compiler, {
|
|
publicPath: config.output.publicPath,
|
|
index: true,
|
|
})
|
|
);
|
|
|
|
app.use(favicon("./favicon.png"));
|
|
|
|
app.get("/login", async (req, res) => {
|
|
try {
|
|
res.redirect(`${API.prefix}login?dataset=http://localhost:${CLIENT_PORT}`);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
});
|
|
|
|
app.get("/logout", async (req, res) => {
|
|
try {
|
|
res.redirect(`${API.prefix}logout?dataset=http://localhost:${CLIENT_PORT}`);
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
});
|
|
|
|
app.listen(CLIENT_PORT, (err) => {
|
|
if (err) {
|
|
console.log(err);
|
|
return;
|
|
}
|
|
|
|
utils.clearConsole();
|
|
console.log(chalk.cyan("Starting the development server..."));
|
|
console.log();
|
|
});
|