From 73c867ebc80e9c0ee54e6a75388a49d064a94cf9 Mon Sep 17 00:00:00 2001 From: rmt/src <144435+rmtsrc@users.noreply.github.com> Date: Sun, 18 Jun 2023 16:02:46 +0100 Subject: [PATCH] Import baseUrl from config --- src/config.ts | 3 ++- tsconfig.vite-config.json | 2 +- vite.config.ts | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index 2558d038..808708fb 100644 --- a/src/config.ts +++ b/src/config.ts @@ -63,7 +63,8 @@ export const config = figue({ .loadEnv({ ...import.meta.env, // Because the string 'import.meta.env.PACKAGE_VERSION' is statically replaced during build time (see 'define' in vite.config.ts) - PACKAGE_VERSION: import.meta.env.PACKAGE_VERSION, + PACKAGE_VERSION: import.meta.env?.PACKAGE_VERSION, + BASE_URL: import.meta.env?.BASE_URL || process.env.BASE_URL, }) .validate() .getConfig(); diff --git a/tsconfig.vite-config.json b/tsconfig.vite-config.json index d20d8726..1e295563 100644 --- a/tsconfig.vite-config.json +++ b/tsconfig.vite-config.json @@ -1,6 +1,6 @@ { "extends": "@vue/tsconfig/tsconfig.node.json", - "include": ["vite.config.*"], + "include": ["vite.config.*", "./src/config.*"], "compilerOptions": { "composite": true, "types": ["node", "vitest"] diff --git a/vite.config.ts b/vite.config.ts index f6b236ab..3ad35591 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,6 +15,7 @@ import { configDefaults } from 'vitest/config'; import Icons from 'unplugin-icons/vite'; import IconsResolver from 'unplugin-icons/resolver'; import VueI18n from '@intlify/unplugin-vue-i18n/vite'; +import { config } from './src/config'; // https://vitejs.dev/config/ export default defineConfig({ @@ -55,7 +56,7 @@ export default defineConfig({ description: 'Aggregated set of useful tools for developers.', display: 'standalone', lang: 'fr-FR', - start_url: `${process.env.BASE_URL}/?utm_source=pwa&utm_medium=pwa`, + start_url: `${config.app.baseUrl}/?utm_source=pwa&utm_medium=pwa`, orientation: 'any', theme_color: '#18a058', background_color: '#f1f5f9', @@ -92,7 +93,7 @@ export default defineConfig({ }), Unocss(), ], - base: process.env.BASE_URL, + base: config.app.baseUrl, resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)),