This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:teamleadercrm/teamleader-ui
- Loading branch information
Showing
4 changed files
with
72 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,56 @@ | ||
const fs = require('fs'); | ||
const express = require('express'); | ||
const webpack = require('webpack'); | ||
const config = require('../config'); | ||
const server = require('../server/main'); | ||
const webpackConfig = require('../build/webpack.config'); | ||
const debug = require('debug')('app:bin:server'); | ||
|
||
const host = config.server_host; | ||
const port = config.server_port; | ||
const app = express(); | ||
const paths = config.utils_paths; | ||
|
||
// This rewrites all routes requests to the root /index.html file | ||
// (ignoring file requests). If you want to implement universal | ||
// rendering, you'll want to remove this middleware. | ||
app.use(require('connect-history-api-fallback')()); | ||
|
||
// ------------------------------------ | ||
// Apply Webpack HMR Middleware | ||
// ------------------------------------ | ||
if (config.env === 'development') { | ||
const compiler = webpack(webpackConfig); | ||
|
||
debug('Enable webpack dev and HMR middleware'); | ||
app.use(require('webpack-dev-middleware')(compiler, { | ||
publicPath: webpackConfig.output.publicPath, | ||
contentBase: paths.client(), | ||
hot: true, | ||
historyApiFallback: true, | ||
quiet: config.compiler_quiet, | ||
noInfo: config.compiler_quiet, | ||
lazy: false, | ||
stats: config.compiler_stats, | ||
})); | ||
app.use(require('webpack-hot-middleware')(compiler)); | ||
|
||
// Serve static assets from ~/spec/static since Webpack is unaware of | ||
// these files. This middleware doesn't need to be enabled outside | ||
// of development since this directory will be copied into ~/dist | ||
// when the application is compiled. | ||
app.use(express.static(paths.client('static'))); | ||
} else { | ||
debug( | ||
'Server is being run outside of live development mode, meaning it will ' + | ||
'only serve the compiled application bundle in ~/dist. Generally you ' + | ||
'do not need an application server for this and can instead use a web ' + | ||
'server such as nginx to serve your static files.' | ||
); | ||
|
||
// Serving ~/dist by default. Ideally these files should be served by | ||
// the web server and not the app server, but this helps to demo the | ||
// server in production. | ||
app.use(express.static(paths.dist())); | ||
} | ||
|
||
server.listen(port); | ||
app.listen(port); | ||
debug(`HTTP server is now running at http://${host}:${port}.`); |
This file was deleted.
Oops, something went wrong.