如何在 vuepress 中更改构建 shell,以在 '/' 和 '/somedir/' 之间切换 base
How to change the build shell in vuepress, to switch base between '/' and '/somedir/'
我想用vuepress搭建一个博客,并想发布到我的服务器和github页面。
像www.codingyang.com和https://github.com/Rackar/codingyang,但是在config.js中,'base'会被设置为'/'和'/codingyang',使url资源正确.
我可以更改不同的 shell 以使用不同的 congfig.base 构建吗?
"docs:build": "vuepress build docs && node utils/bd_hm.js",
"docs:build:gitpage": "vuepress build docs --codingyang && node utils/bd_hm.js",
"docs:push:gitpage": "push-dir --dir=docs/.vuepress/dist --branch=gh-pages"
喜欢使用 'docs:build' 以 base = '/' 构建 dist/,并将其复制到我的服务器。
使用 'docs:build:gitpage' && 'docs:push:gitpage' 设置 base = 'codingyang ',并在其他开发人员的 github 操作和 github 页面中使用它们?
我可以使用额外的参数或确定环境脚本来做这样的事情吗?
目前,我相信您可以根据环境变量设置基值:
module.exports = {
base: process.env.VUEPRESS_BASE || '/'
}
并在package.json
配置环境变量:
"scripts": {
"docs:build": "vuepress build docs && node utils/bd_hm.js",
"docs:build:gitpage": "VUEPRESS_BASE="/codingyang/" && vuepress build docs --codingyang && node utils/bd_hm.js"
}
参考:
- Issue #560
- How to set environment variable from within package.json
我想用vuepress搭建一个博客,并想发布到我的服务器和github页面。 像www.codingyang.com和https://github.com/Rackar/codingyang,但是在config.js中,'base'会被设置为'/'和'/codingyang',使url资源正确.
我可以更改不同的 shell 以使用不同的 congfig.base 构建吗?
"docs:build": "vuepress build docs && node utils/bd_hm.js",
"docs:build:gitpage": "vuepress build docs --codingyang && node utils/bd_hm.js",
"docs:push:gitpage": "push-dir --dir=docs/.vuepress/dist --branch=gh-pages"
喜欢使用 'docs:build' 以 base = '/' 构建 dist/,并将其复制到我的服务器。
使用 'docs:build:gitpage' && 'docs:push:gitpage' 设置 base = 'codingyang ',并在其他开发人员的 github 操作和 github 页面中使用它们?
我可以使用额外的参数或确定环境脚本来做这样的事情吗?
目前,我相信您可以根据环境变量设置基值:
module.exports = {
base: process.env.VUEPRESS_BASE || '/'
}
并在package.json
配置环境变量:
"scripts": {
"docs:build": "vuepress build docs && node utils/bd_hm.js",
"docs:build:gitpage": "VUEPRESS_BASE="/codingyang/" && vuepress build docs --codingyang && node utils/bd_hm.js"
}
参考:
- Issue #560
- How to set environment variable from within package.json