Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

411
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda