1

I want to use github page on 'vue.js'

I tried to modify /config/index.js file.

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

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

But i can't use github page.

enter image description here

3
  • Do you explicitly want to use the /docs folder option? Isn't the master option not working for you? Commented Jan 5, 2020 at 12:15
  • I want to use /docs folder option. Commented Jan 5, 2020 at 17:17
  • And do you have a docs folder in the root of the repo? Just tried replaying what you describe in your question and had no issues. Commented Jan 5, 2020 at 18:14

1 Answer 1

1

This should work: the "Vue.js / Deployment / Platform Guides GitHub Pages/ " documentation simply adds:

If you are deploying to https://<USERNAME>.github.io/<REPO>/, (i.e. your repository is at https://github.com/<USERNAME>/<REPO>), set publicPath to "/<REPO>/".
For example, if your repo name is "my-project", your vue.config.js should look like this:

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

toast38coza illustrates that setup in his blog post:

Step 1: Setup the build system to build to /docs

Edit: config/index.js

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

Run:

npm run build

You should now have a docs folder in your project. Add and push to GitHub.

Check if those settings work better in your case.

Sign up to request clarification or add additional context in comments.

1 Comment

I got the problem "npm run build".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.