// vite.config.js
import {
defineConfig
} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
// https://vitejs.dev/config/
export default defineConfig({
base: 'http://uc.***.com/ssr/',
plugins: [
uni(),
],
ssr: {
format: 'cjs'
}
})
// 同时勾选SSR和托管生成的index.html
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://uc.***.com/assets/uni.a98d87c5.css">
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title>web-ssr</title>
<!--preload-links-->
<!--app-context-->
<script type="module" crossorigin src="https://uc.***.com/assets/index-d6d58429.js"></script>
<link rel="stylesheet" href="https://uc.***.com/assets/index-f8a6efe7.css">
</head>
<body>
<div id="app"><!--app-html--></div>
</body>
</html>
// 只勾选SSR生成的index.html
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="http://uc.***.com/ssr/assets/uni.a98d87c5.css">
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title>web-ssr</title>
<!--preload-links-->
<!--app-context-->
<script type="module" crossorigin src="http://uc.***.com/ssr/assets/index-d6d58429.js"></script>
<link rel="stylesheet" href="http://uc.***.com/ssr/assets/index-f8a6efe7.css">
</head>
<body>
<div id="app"><!--app-html--></div>
</body>
</html>
3 个回复
蜡笔小鑫 (作者)
现在我只能选择本地发布,然后手动上传uni_ssr和前端。比较麻烦。
mvlyforever
怎么本地发布,我这边也是 发布之后 导航出现了两遍。 本地运行是好的
mvlyforever
我的问题已解决。 image 不能被 navigator 包裹,不然会编译会导致页面出现异常 谢谢。