Commit 06454261 authored by 前端-许佳敏's avatar 前端-许佳敏

新增构建后本地访问脚本

parent 8b799503
......@@ -7,6 +7,7 @@
"scripts:build": "node scripts/run",
"start": "yarn api && yarn scripts:build && umi dev",
"build": "yarn api && yarn scripts:build && umi build",
"build:dev": "pm2 start scripts/devServer.js",
"build:analyze": "ANALYZE=1 umi build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
......@@ -45,6 +46,8 @@
},
"devDependencies": {
"axios": "^0.19.2",
"connect-history-api-fallback": "^1.6.0",
"express": "^4.17.1",
"god-yapi2ts": "^1.6.0",
"gulp": "^4.0.2",
"json2ts": "^0.0.7",
......
/**
* 用于build后在10.0.0.25环境下,作为本地调试
*
*/
//express模块
var express =require("express");
var app =express();
const path = require('path')
const port = 4398
// 用于解决刷新后404问题
var history = require('connect-history-api-fallback');
app.use(history());
app.use(express.static('dist'))
app.get('/',(req,res)=>{
res.sendFile(path.resolve(__dirname, "../dist/", "index.html")) //设置/ 下访问文件位置
});
var server =app.listen(port,()=>{
var port =server.address().port
console.log("【】访问地址http://localhost:%s",port)
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment