Solving Path Problems When Deploying Vue.js in Subdirectories

Forums How to solve Solving Path Problems When Deploying Vue.js in Subdirectories

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9390
    albanaavdiu
    Participant

    I’m working on a Vue 3 project and planning to deploy it, but I want to host it in a subdirectory of my domain, not in the root directory. However, I’m encountering problems with paths.How to solve it ?

    • This topic was modified 1 year, 8 months ago by albanaavdiu.
    #9392
    albanaavdiu
    Participant

    In Vue 3, the ‘base‘ option is used to specify the base URL for all relative URLs in your application. This is useful when your Vue application is not deployed at the root of your domain but in a subdirectory.

    (In VUE 2 assetsPublicPath: ‘/markataepeshkut’)

    (In VUE 3 base: ‘/markataepeshkut’)

     

    vite.config.ts

    import { fileURLToPath, URL } from ‘node:url’

    import { defineConfig } from ‘vite’
    import vue from ‘@vitejs/plugin-vue’

    // https://vitejs.dev/config/
    export default defineConfig({
    plugins: [vue()],
    base: ‘/markataepeshkut/’,
    resolve: {
    alias: {
    ‘@’: fileURLToPath(new URL(‘./src’, import.meta.url))
    }
    }
    })

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.