Deploy VueJS App in a subdirectory

For Vue CLI 3 it is pretty simple.

Edit your vue.config.js (if there is none, create it in project root directory) and add following lines:

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

Or whatever sub-directory you want.

You may also decide according to NODE_ENV. See the docs.

module.exports = {
  baseUrl: process.env.NODE_ENV === 'production'
    ? '/production-sub-path/'
    : "https://stackoverflow.com/"
}

UPDATE

As mentioned in comments below, for Vue CLI 3.3+ use publicPath property instead of baseUrl.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)