build and publish dist folder to github pages

Question3r

I created a project with Vue.js and Vuetify using the Vue CLI. I would like to host this application with Github Pages. So I took a guide from here

https://help.github.com/en/articles/configuring-a-publishing-source-for-github-pages#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch

and I am not using the history moute of the Vue Router (https://router.vuejs.org/guide/essentials/history-mode.html) to make sure I don't need a server.

I created a build of my project and renamed the generated dist folder to docs. This docs folder is placed in the root directory (where it was generated). When I select master branch /docs folder as my Github Pages publishing source I get a blank white page.

When I check the console I get a

Failed to load resource: the server responded with a status of 404 ()

for each file generated in the dist/docs folder. What am I missing?

Brandon Franklin

This could be that the root path of your app is set to look at the root of your github instead of the root of the repository.

It also looks like you are using vue-cli-3 from the tags. So here is what I have done for deploying a Vue app to be hosted on github pages.

  1. Create a vue.config.js file in the root of your app.

  2. In that file, set the public path to match the repository name.

module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? '/YOUR_REPO_NAME/' : '/'
}
  1. Create a deploy.sh file in the root of your app.

  2. In the file, write the following

set -e

npm run build

cd dist

git init
git add -A
git commit -m 'deploy'

git push -f [email protected]:YOUR_USER_NAME/REPOSITORY_NAME.git master:gh-pages

cd -
  1. Now from the command line, in the root of your app, you can run sh deploy.sh. This will run the build command for vue-cli, go into the dist folder, commit those files and push them to the gh-pages branch.

  2. Then you can set your github repo to use gh-pages instead of docs. Since you mentioned you are not using history mode for vue-router, you should see the # in the URL string and it will work when a user refreshed the page on a different route other than home.

Hope that helps point you in the right direction for deploying and hosting your Vue app on github pages.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to force GitHub Pages build?

How to publish a website made by Node.js to Github Pages?

Folder naming: src & dist vs. src & build, dev & dist

How to publish versioned JavaDoc/Site to github pages in Java project?

What to do with a build "dist" folder

host github pages from /dist folder in master branch

Github Pages 404 on node_modules folder

how to publish to github pages?

How to "build" contents of a node application to a folder called "dist"

npm publish a package with only the children of dist folder

Deploying ignored dist folder to GitHub Pages

How to publish a dist folder in npm

Unable to build to Github Pages

publish only one folder on gitHub on a parallel branch

GitHub Pages: README.md in docs folder

ng build --prod doesn't generate dist folder

"npm run build" in Dockerfile: dist folder is generated but disappears

Force github pages to use _site folder

Automating the build and publish process with GitHub Actions (and GitHub Package Registry)

AzureDevOps Duplicate dist folder in pipelines build ? Why?

Override publish folder (url) of publish profile during the build pipeline

publish dist folder to github pages

Publish React app to Github Pages using github Actions

How to publish a Ionic 5 website on GitHub pages?

How Angular dist folder(After build) works with multiple projects

Grunt build not including bower components in dist folder

GitHub pages page not build correctly?

How to deploy a project on GitHub Pages from dist folder

Copy contents of AddedFiles folder to dist folder, after build

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive