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

fix(h5): respect user config (#3083)

上级 677656cf
import fs from 'fs'
import path from 'path'
import type { Plugin, ResolvedConfig } from 'vite'
import type { Plugin, ResolvedConfig, ServerOptions } from 'vite'
import {
isInHBuilderX,
normalizePath,
......@@ -9,6 +9,7 @@ import {
import { createDefine, isSsr } from '../utils'
import { esbuildPrePlugin } from './esbuild/esbuildPrePlugin'
import { external } from './configureServer/ssr'
import { extend, hasOwn } from '@vue/shared'
export function createConfig(options: {
resolvedConfig: ResolvedConfig | null
}): Plugin['config'] {
......@@ -21,6 +22,26 @@ export function createConfig(options: {
process.exit()
}
}
const server: ServerOptions = {
host: true,
fs: { strict: false },
watch: {
ignored: ['**/uniCloud**'],
},
}
const { server: userServer } = config
if (userServer) {
if (hasOwn(userServer, 'host')) {
server.host = userServer.host
}
if (hasOwn(userServer, 'fs')) {
extend(server.fs, userServer.fs)
}
if (hasOwn(userServer, 'watch')) {
extend(server.watch, userServer.watch)
}
}
return {
optimizeDeps: {
entries: resolveMainPathOnce(process.env.UNI_INPUT_DIR),
......@@ -30,15 +51,7 @@ export function createConfig(options: {
},
},
define: createDefine(env.command, config),
server: {
host: true,
fs: {
strict: false,
},
watch: {
ignored: ['**/uniCloud**'],
},
},
server,
ssr: {
external,
},
......
......@@ -9,7 +9,7 @@ import { initEnv, printStartupDuration } from './utils'
import { initEasycom } from '../utils/easycom'
export async function runDev(options: CliOptions & ServerOptions) {
extend(options, { watch: true, minify: false })
extend(options, { watch: {}, minify: false })
initEnv('dev', options)
try {
if (options.platform === 'h5') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册