Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Vuejs2 build subpath

01 Oct 2022 »

13oct24

https://stackoverflow.com/questions/66284893/how-do-you-control-your-publicpath-property-in-vue-config-js

function getPublicPath() {
  switch (process.env.NODE_ENV) {
    case 'production': return '/ProductionEnv/'
    case 'qa': return '/QaEnv/'
    case 'dev': return '/DevEnv/'
    case 'stage': return '/StageEnv/'
    default: return ''
  }
}

module.exports = {
  publicPath: getPublicPath()
}

https://cli.vuejs.org/config/#publicpath

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

original

https://medium.com/h-lab/how-to-deploy-vue-with-nginx-on-sub-path-ed8eadbc1bc5

vue.config.js

module.exports = {
  publicPath: process.env.APP_BASE_PATH
}

Vuej3

https://stackoverflow.com/questions/43879418/deploy-vuejs-app-in-a-subdirectory

module.exports = {
  baseUrl: "./"
};