ludu-cloud/mobile-web/server/server.prod.js

37 lines
888 B
JavaScript
Raw Normal View History

2019-03-26 13:18:53 +08:00
const path = require('path');
const express = require('express');
const { chalkSuccess } = require('./config/chalk.config');
const proxyConfig = require('./config/proxy.prod.config');
const proxyBuild = require('./utils/proxy.build');
// create app server
const app = express();
2019-03-26 13:19:46 +08:00
const port = 3100;
2019-03-26 13:18:53 +08:00
// host proxy
app.use(proxyBuild(proxyConfig));
// use index.html
app.use(express.static(path.join(__dirname, 'dist/css')));
app.use(express.static(path.join(__dirname, 'dist/js')));
app.use(express.static(path.join(__dirname, 'dist')));
app.use((req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
});
app.listen(port, error => {
if (error) {
console.error(error);
} else {
console.info(
chalkSuccess(
'==> 🌎 Listening on port %s. ' + 'Open up http://localhost:%s/ in your browser.'
),
port,
port
);
}
});