16 lines
575 B
JavaScript
16 lines
575 B
JavaScript
|
|
const connect = require('connect');
|
||
|
|
const serveStatic = require('serve-static');
|
||
|
|
const chalk = require('chalk');
|
||
|
|
const path = require('path');
|
||
|
|
|
||
|
|
const port = process.env.PORT ? Number(process.env.PORT) : 9526;
|
||
|
|
const mountPath = '/srs'; // 与生产 publicPath 保持一致
|
||
|
|
const distDir = path.resolve(__dirname, '..', 'dist');
|
||
|
|
|
||
|
|
const app = connect();
|
||
|
|
app.use(mountPath, serveStatic(distDir, { index: ['index.html', '/'] }));
|
||
|
|
|
||
|
|
app.listen(port, () => {
|
||
|
|
const url = `http://localhost:${port}${mountPath}/`;
|
||
|
|
console.log(chalk.green(`> Static preview running at ${url}`));
|
||
|
|
});
|