Skip to content

Multiple values for "base" configuration #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hanxue opened this issue Jun 8, 2018 · 6 comments
Closed

Multiple values for "base" configuration #560

hanxue opened this issue Jun 8, 2018 · 6 comments

Comments

@hanxue
Copy link

hanxue commented Jun 8, 2018

Feature request

I need to have the ability to set different values of base for deployment to multiple sites. My default deployment for the site is OK with the default, unspecified value for base because the content is deployed to https://www.wujiquan.net

I also want to have a development deployment to https://hanxue.github.io/wujiquan-vuepress/ , to the gh-pages branch. Without setting base to wujiquan-vuepress, the Github Pages site will not work

What problem does this feature solve?

Allowing multiple deployments with differing settings of base.

Is there any option to set configuration values via environment variables, or to specify a different configuration file other than the default config.js?

@yyx990803
Copy link
Member

yyx990803 commented Jun 8, 2018

You can just set the base value depending on an environment variable:

module.exports = {
  base: process.env.VUEPRESS_BASE || '/'
}

@VyaWave
Copy link

VyaWave commented Aug 14, 2018

hi , I have met a question. in confg.js i set

module.exports = {
    base: process.env.NODE_ENV === 'development' ? '/magic-wpress/' : '/',  
}

why it don't work ?
thanks

@yyx990803

@Krutie
Copy link

Krutie commented May 11, 2019

@RVYA Did you ever figure out how to set multiple values in config.js for VuePress base?

@ulivz
Copy link
Member

ulivz commented May 11, 2019

@RVYA @kru

The environment variable NODE_ENV was not injected when config.js was read, so you need to set the environment variable in your package.json.

@Mister-Hope
Copy link
Contributor

Mister-Hope commented Sep 17, 2019

Excuse me, my question is that I want to use the same code to automatically deploy on /XXX/ and /.
So what can I do?

I searched how to set environment variable in package.json, but how to dynamic set it?

Could you tell me more specificlly?

@nielsnuebel
Copy link

You can use npm i -D cross-env

in your package.json
"docs:build": "cross-env NODE_ENV=production vuepress build docs"

in config.js
module.exports = { base: process.env.NODE_ENV === 'production'? '/github_repo/': '/' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants