1 parent
519e2b4a5f
commit
d7837de561
45 files changed
+1588
-109
No files matched your search
@@ -1,5 +1 @@
|
||||
VITE_DEV_BACKEND_URL=http://127.0.0.1:5201
|
||||
VITE_DEV_BACKEND_ORIGIN=https://xuans.com
|
||||
VITE_DEV_FRONTEND_ORIGIN=https://xuans.com
|
||||
SMAIL_DEV_TLS_CERTIFICATE=../data/ssl/xuans.com.crt
|
||||
SMAIL_DEV_TLS_PRIVATE_KEY=../data/ssl/xuans.com.key
|
||||
@@ -1,13 +1,13 @@
|
||||
/* eslint-env node */
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { createServer as createHTTPServer } from 'node:http'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { readDevelopmentRuntime } from '../deploy/runtime-config.mjs'
|
||||
|
||||
const developmentHTTPRedirect = (frontendOrigin, host = '127.0.0.1', port = 80) => ({
|
||||
name: 'smail-development-http-redirect',
|
||||
@@ -35,10 +35,9 @@ const developmentHTTPRedirect = (frontendOrigin, host = '127.0.0.1', port = 80)
|
||||
export default defineConfig(({ mode, command }) => {
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
const backendUrl = (env.VITE_DEV_BACKEND_URL || 'http://127.0.0.1:5201').replace(/\/$/, '')
|
||||
const backendOrigin = (env.VITE_DEV_BACKEND_ORIGIN || 'https://xuans.com').replace(/\/$/, '')
|
||||
const frontendOrigin = (env.VITE_DEV_FRONTEND_ORIGIN || 'https://xuans.com').replace(/\/$/, '')
|
||||
const certificatePath = path.resolve(process.cwd(), env.SMAIL_DEV_TLS_CERTIFICATE || '../data/ssl/xuans.com.crt')
|
||||
const privateKeyPath = path.resolve(process.cwd(), env.SMAIL_DEV_TLS_PRIVATE_KEY || '../data/ssl/xuans.com.key')
|
||||
const runtime = command === 'serve' ? readDevelopmentRuntime() : undefined
|
||||
const backendOrigin = runtime?.origin
|
||||
const frontendOrigin = runtime?.origin
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
@@ -62,8 +61,8 @@ export default defineConfig(({ mode, command }) => {
|
||||
strictPort: true,
|
||||
// 生产构建不依赖本机开发证书,只有开发服务器启动时才读取私钥。
|
||||
https: command === 'serve' ? {
|
||||
cert: readFileSync(certificatePath),
|
||||
key: readFileSync(privateKeyPath)
|
||||
cert: readFileSync(runtime.certificatePath),
|
||||
key: readFileSync(runtime.privateKeyPath)
|
||||
} : undefined,
|
||||
cors: true,
|
||||
proxy: {
|
||||
|
||||
Reference in new issue
Block a user