((Vue.js)如何在'Vue.js'上使用github页面”

问题描述 投票:1回答:1

我想在'vue.js'上使用github页面

我试图修改/config/index.js文件。

build: {
    // Template for index.html
    index: path.resolve(__dirname, '../docs/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../docs'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '',

但是我不能使用github页面。enter image description here

vue.js github github-pages
1个回答
0
投票

这应该起作用:“ Vue.js / Deployment / Platform Guides GitHub Pages/ ”文档只需添加:

[如果要部署到https://<USERNAME>.github.io/<REPO>/,(即,您的存储库位于https://github.com/<USERNAME>/<REPO>),请将publicPath设置为“ /<REPO>/”。例如,如果您的回购名称为“ my-project”,则您的vue.config.js应如下所示:

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

[toast38coza说明在他的blog post中进行的设置:

步骤1:设置要构建到/docs的构建系统>

编辑:config/index.js

find ../dist replace with ../docs
change assetsPublicPath: '/', to: assetsPublicPath: './',

运行:

npm run build

您现在应该在项目中有一个docs文件夹。添加并推送到github

© www.soinside.com 2019 - 2024. All rights reserved.