build: generate build with admin as the base for subpath based access

This commit is contained in:
jamesgeorge007
2023-10-24 13:52:22 +05:30
parent 03e21e0b0c
commit 8703a0dcfd
4 changed files with 10 additions and 3 deletions

View File

@@ -59,3 +59,6 @@ VITE_BACKEND_API_URL=http://localhost:3170/v1
# Terms Of Service And Privacy Policy Links (Optional)
VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms
VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy
# Set to `true` for subpath based access
VITE_INCLUDE_ADMIN_PREFIX=false

View File

@@ -41,8 +41,10 @@ export const isLoadingInitialRoute = readonly(_isLoadingInitialRoute);
export default <HoppModule>{
onVueAppInit(app) {
const basePath = import.meta.env.PROD && import.meta.env.VITE_INCLUDE_ADMIN_PREFIX === 'true' ? '/admin' : undefined
const router = createRouter({
history: createWebHistory('/admin'),
history: createWebHistory(basePath),
routes,
});

View File

@@ -6,7 +6,7 @@
:class="{ 'min-h-screen': statusCode !== 404 }"
>
<img
:src="`/images/youre_lost.svg`"
:src="imgUrl"
loading="lazy"
class="inline-flex flex-col object-contain object-center mb-2 h-46 w-46"
:alt="message"
@@ -44,6 +44,9 @@ const props = defineProps({
},
});
const imgPrefix = import.meta.env.PROD && import.meta.env.VITE_INCLUDE_ADMIN_PREFIX === 'true' ? '/admin' : ''
const imgUrl = `${imgPrefix}/images/youre_lost.svg`
const statusCode = computed(() => props.error?.statusCode ?? 404);
const message = computed(

View File

@@ -15,7 +15,6 @@ import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
export default defineConfig({
envPrefix: process.env.HOPP_ALLOW_RUNTIME_ENV ? 'VITE_BUILDTIME_' : 'VITE_',
envDir: path.resolve(__dirname, '../..'),
base: '/admin/',
server: {
port: 3100,
},