Follow the steps below to deploy to GitHub Pages using parcel-bundler
-
Create a new branch called
deployed-solution
and switch to it. -
Install
parcel-bundler
yarn add --dev parcel-bundler@1.12.5
-
Install
gh-pages
yarn add --dev gh-pages
-
Remove
script
tag with"./node_modules/axios/dist/axios.min.js"
fromindex.html
-
Add
import
statements toindex.js
import 'regenerator-runtime/runtime'; import axios from 'axios';
-
Add a
"scripts"
section to yourpackage.json
:"scripts": { "predeploy": "rm -rf dist && yarn run build", "deploy": "gh-pages -d dist", "test": "echo \"Error: no test specified\" && exit 1", "dev": "parcel index.html ", "build": "parcel build index.html --public-url /weather-report/" }
Complete
package.json
{ "dependencies": { "axios": "^0.27.2" }, "devDependencies": { "gh-pages": "^4.0.0", "parcel-bundler": "^1.12.5" }, "scripts": { "predeploy": "rm -rf dist && yarn run build", "deploy": "gh-pages -d dist", "test": "echo \"Error: no test specified\" && exit 1", "dev": "parcel index.html ", "build": "parcel build index.html --public-url /weather-report/" } }
-
Run
yarn run deploy
-
Confirm that the GitHub Pages branch is set to
gh-pages
in the GitHub UI by going to Settings --> Pages --> Source -
Navigate to
https://{your-user-name}.github.io/weather-report/
to see your deployed site.