Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

412
Vistas
Unable to change the publicPath in Vue 3 with Vite.js

I am trying to change the public path for production build but can't seem to get it to work. When I build for production, I would like to change the public path from / to ./ but I could not find anything in the documentation how to do this. I am using vite.js as my build tool. Maybe this is something Vue 3 and Vite specific, I'm not sure.

I have tried adding a vue.config.js file and also .env variables but so far nothing is working.

When I build, I get this output with path starting with /:

<head>
  <script src="/assets/index.30c61b3b.js"></script>
  <link href="/assets/vendor.29497e16.js">
  <link href="/assets/index.7123a98f.css">
</head>

But for production I would like it to change to ./ like this:

<head>
  <script src="./assets/index.30c61b3b.js"></script>
  <link href="./assets/vendor.29497e16.js">
  <link href="./assets/index.7123a98f.css">
</head>

I tried adding vue.config.js but it is not helping:

module.exports  = {
    publicPath: process.env.NODE_ENV  ===  'production'  ?  './'  :  '/'
}

and also .env

NODE_ENV=production
BASE_URL=./
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found the answer, I needed to add a base option to vite.config.js like this:

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

export default defineConfig({
    plugins: [
        vue({
            reactivityTransform: true
        })
    ],

    base: './',
})

https://vitejs.dev/config/#base

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda