Files
zhxg_pc/build/preview-static.js

16 lines
575 B
JavaScript
Raw Normal View History

2025-10-22 11:51:32 +08:00
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}`));
});