Merge remote-tracking branch 'origin/develop' into biome
This commit is contained in:
commit
851c100a24
15 changed files with 576 additions and 65 deletions
|
|
@ -5,6 +5,7 @@ import vueJsx from '@vitejs/plugin-vue-jsx'
|
|||
import { defineConfig } from 'vite'
|
||||
import eslint from 'vite-plugin-eslint2'
|
||||
import stylelint from 'vite-plugin-stylelint'
|
||||
import { configDefaults } from 'vitest/config'
|
||||
import { getCommitHash } from './build/commit_hash.js'
|
||||
import copyPlugin from './build/copy_plugin.js'
|
||||
import emojisPlugin from './build/emojis_plugin.js'
|
||||
|
|
@ -16,23 +17,37 @@ import {
|
|||
} from './build/sw_plugin.js'
|
||||
|
||||
const localConfigPath = '<projectRoot>/config/local.json'
|
||||
const normalizeTarget = (target) => {
|
||||
if (!target || typeof target !== 'string') return target
|
||||
return target.endsWith('/') ? target.replace(/\/$/, '') : target
|
||||
}
|
||||
|
||||
const getLocalDevSettings = async () => {
|
||||
const envTarget = normalizeTarget(process.env.VITE_PROXY_TARGET)
|
||||
const envOrigin = normalizeTarget(process.env.VITE_PROXY_ORIGIN)
|
||||
try {
|
||||
const settings = (await import('./config/local.json')).default
|
||||
if (settings.target && settings.target.endsWith('/')) {
|
||||
// replacing trailing slash since it can conflict with some apis
|
||||
// and that's how actual BE reports its url
|
||||
settings.target = settings.target.replace(/\/$/, '')
|
||||
}
|
||||
settings.target = normalizeTarget(settings.target)
|
||||
settings.origin = normalizeTarget(settings.origin)
|
||||
if (envTarget) settings.target = envTarget
|
||||
if (envOrigin) settings.origin = envOrigin
|
||||
console.info(`Using local dev server settings (${localConfigPath}):`)
|
||||
console.info(JSON.stringify(settings, null, 2))
|
||||
return settings
|
||||
} catch (e) {
|
||||
if (!envTarget && !envOrigin) {
|
||||
console.info(
|
||||
`Local dev server settings not found (${localConfigPath}), using default`,
|
||||
e,
|
||||
)
|
||||
return {}
|
||||
}
|
||||
const settings = { target: envTarget, origin: envOrigin }
|
||||
console.info(
|
||||
`Local dev server settings not found (${localConfigPath}), using default`,
|
||||
e,
|
||||
'Using dev server settings from VITE_PROXY_TARGET/VITE_PROXY_ORIGIN:',
|
||||
)
|
||||
return {}
|
||||
console.info(JSON.stringify(settings, null, 2))
|
||||
return settings
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +73,7 @@ const getTransformSWSettings = (settings) => {
|
|||
export default defineConfig(async ({ mode, command }) => {
|
||||
const settings = await getLocalDevSettings()
|
||||
const target = settings.target || 'http://localhost:4000/'
|
||||
const origin = settings.origin || target
|
||||
const transformSW = getTransformSWSettings(settings)
|
||||
const proxy = {
|
||||
'/api': {
|
||||
|
|
@ -77,7 +93,7 @@ export default defineConfig(async ({ mode, command }) => {
|
|||
cookieDomainRewrite: 'localhost',
|
||||
ws: true,
|
||||
headers: {
|
||||
Origin: target,
|
||||
Origin: origin,
|
||||
},
|
||||
},
|
||||
'/oauth': {
|
||||
|
|
@ -225,6 +241,7 @@ export default defineConfig(async ({ mode, command }) => {
|
|||
},
|
||||
test: {
|
||||
globals: true,
|
||||
exclude: [...configDefaults.exclude, 'test/e2e-playwright/**'],
|
||||
browser: {
|
||||
enabled: true,
|
||||
provider: 'playwright',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue