- 添加开发、生产和预发布环境配置文件 - 配置不同环境的API接口地址和压缩选项 - 创建401和404错误页面组件 - 添加生产相关的操作对话框和历史记录组件 - 集成仓库代理功能API - 添加应用状态管理模块 - 创建基础样式定义文件
18 lines
757 B
JavaScript
18 lines
757 B
JavaScript
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
|
|
// Serve generated page-update artifacts only, matching the previous dev server.
|
|
export default function mobileUpdate() {
|
|
return {name:'cmvr-mobile-update',configureServer(server){
|
|
server.middlewares.use((req,res,next)=>{
|
|
const name=(req.url||'').split('?')[0].slice(1)
|
|
if(name!=='mobile-update.json'&&!/^web-[a-f0-9]{24}\.zip$/.test(name))return next()
|
|
const file=path.resolve(server.config.root,'dist',name)
|
|
if(!fs.existsSync(file)){res.statusCode=404;res.end();return}
|
|
res.setHeader('Cache-Control','no-store')
|
|
res.setHeader('Content-Type',name.endsWith('.json')?'application/json':'application/zip')
|
|
fs.createReadStream(file).pipe(res)
|
|
})
|
|
}}
|
|
}
|