Files
cellxgene/client/server/development.js
Matt Weiden ac13b31e13 Collect all env vars in one, easy-to-find place (#1149)
* Collect all env vars in one, easy-to-find place

Past state:
* Default environement variables were stored in both client/package.json
and client/__tests__/e2e/config.js
* Constants that should have been linked--like the cellxgene server port
during testing--were repeated.

With this commit:
* All environment variables are parameterized
* All environment variables are packaged in default env files

* Move npm scripts to client Makefile

* Respond to feedback from @seve and @bkmartinjr
2020-02-12 12:50:48 -08:00

56 lines
1.2 KiB
JavaScript

/* eslint-disable */
// jshint esversion: 6
var path = require("path");
var historyApiFallback = require("connect-history-api-fallback");
var chalk = require("chalk");
var express = require("express");
var favicon = require("serve-favicon");
var webpack = require("webpack");
var config = require("../configuration/webpack/webpack.config.dev");
var utils = require("./utils");
process.env.NODE_ENV = "development";
const CLIENT_PORT = process.env.CXG_CLIENT_PORT;
// Set up compiler
var compiler = webpack(config);
compiler.plugin("invalid", () => {
utils.clearConsole();
console.log("Compiling...");
});
compiler.plugin("done", stats => {
utils.formatStats(stats, CLIENT_PORT);
});
// Launch server
var app = express();
app.use(historyApiFallback({ verbose: false }));
app.use(
require("webpack-dev-middleware")(compiler, {
logLevel: "warn",
publicPath: config.output.publicPath
})
);
app.use(favicon("./favicon.png"));
app.get("*", (req, res) => {
res.sendFile(path.resolve("index.html"));
});
app.listen(CLIENT_PORT, err => {
if (err) {
console.log(err);
return;
}
utils.clearConsole();
console.log(chalk.cyan("Starting the development server..."));
console.log();
});