提交 1703f6ea 编写于 作者: fxy060608's avatar fxy060608

feat(ssr): copy index.html

上级 fbfab5bf
......@@ -2,10 +2,11 @@ import { createSSRApp } from 'vue'
import App from './App.vue'
import createStore from './store'
export function createApp() {
const store = createStore()
const app = createSSRApp(App)
const store = createStore()
app.use(store)
// `trace` 是组件的继承关系追踪
app.config.warnHandler = function (msg) {
const ssrLogElem = document.getElementById('ssr-log')
ssrLogElem && (ssrLogElem.innerHTML = ssrLogElem.innerHTML + '\n' + msg)
......
......@@ -56,11 +56,11 @@ export async function buildSSR(options: CliOptions) {
build: ssrBuildServerOptions,
})
// copy ssr-manfiest.json to server
const ssrManifestFile = path.join(ssrClientDir, 'ssr-manifest.json')
if (fs.existsSync(ssrManifestFile)) {
fs.copyFileSync(
ssrManifestFile,
path.join(ssrServerDir, 'ssr-manifest.json')
)
}
const assets = ['ssr-manifest.json', 'index.html']
assets.forEach((asset) => {
const ssrManifestFile = path.join(ssrClientDir, asset)
if (fs.existsSync(ssrManifestFile)) {
fs.copyFileSync(ssrManifestFile, path.join(ssrServerDir, asset))
}
})
}
import path from 'path'
import debug from 'debug'
import slash from 'slash'
import { Plugin, ResolvedConfig } from 'vite'
import { VitePluginUniResolvedOptions } from '../..'
import { isSsr, isSsrManifest } from '../../utils'
const debugMain = debug('vite:uni:main')
export function uniMainJsPlugin(
config: ResolvedConfig,
options: VitePluginUniResolvedOptions
......@@ -25,8 +28,10 @@ export function uniMainJsPlugin(
} else {
code = ssr ? createSSRServerApp(code) : createSSRClientApp(code)
}
code = `import { plugin } from '@dcloudio/uni-h5';import '${pagesJsonJsPath}';${code}`
debugMain(code)
return {
code: `import { plugin } from '@dcloudio/uni-h5';import '${pagesJsonJsPath}';${code}`,
code,
map: this.getCombinedSourcemap(),
}
}
......
......@@ -16,7 +16,8 @@ const priority = {
'uni-cli-shared': 60,
'uni-h5': 50,
'uni-h5-vue': 40,
'vite-plugin-uni': 30,
'uni-app-plus': 30,
'vite-plugin-uni': 20,
'size-check': 1,
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册