Skip to content

Commit 686fd95

Browse files
committed
add final changes
1 parent 64e46a8 commit 686fd95

File tree

4 files changed

+636
-4
lines changed

4 files changed

+636
-4
lines changed

README.md

Lines changed: 167 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,169 @@
1-
# Vue 3 + Vite
1+
![image](./public/snap.png)
22

3-
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
3+
![Static Badge](https://img.shields.io/badge/vue-v3%2e4%2e31-42d392) ![Static Badge](https://img.shields.io/badge/tailwindcss-v3%2e4%2e7-38bdf8)
44

5-
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
5+
"[Vue](https://vuejs.org/) is a JavaScript framework for building user interfaces. It builds on top of standard HTML, CSS, and JavaScript and provides a declarative, component-based programming model that helps you efficiently develop user interfaces of any complexity."
6+
7+
This guide provides a first-hand experience on building a Vue project using [Vite](https://vitejs.dev/guide/#scaffolding-your-first-vite-project) + [Tailwind CSS](https://tailwindcss.com/docs/guides/sveltekit) and deploying it on [GitHub Pages](https://pages.github.com/).
8+
9+
## 🛠️ Installation
10+
11+
**1. Create your project.**
12+
You can use the [official guide](https://vuejs.org/guide/quick-start#creating-a-vue-application) or use **Vite** like this.
13+
14+
```bash
15+
# terminal
16+
npm create vite@latest project_name -- --template vue
17+
cd project_name
18+
```
19+
20+
**2. Install Tailwind CSS.**
21+
22+
```bash
23+
# terminal
24+
npm install -D tailwindcss postcss autoprefixer
25+
npx tailwindcss init -p
26+
```
27+
28+
**3. Configure template paths.**
29+
30+
```js
31+
// tailwind.config.js
32+
/** @type {import('tailwindcss').Config} */
33+
export default {
34+
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
35+
theme: {
36+
extend: {},
37+
},
38+
plugins: [],
39+
};
40+
```
41+
42+
**4. Add the Tailwind directives.**
43+
44+
```css
45+
/* ./src/style.css */
46+
@tailwind base;
47+
@tailwind components;
48+
@tailwind utilities;
49+
```
50+
51+
**5. Start your build process.**
52+
53+
```bash
54+
# terminal
55+
npm run dev
56+
```
57+
58+
**6. Happy coding. ^^**
59+
60+
```html
61+
<!-- App.vue -->
62+
<template>
63+
<h1 class="text-3xl font-bold underline">Hello world!</h1>
64+
</template>
65+
```
66+
67+
## 🗂️ File Structure
68+
69+
Sample project structure.
70+
71+
```
72+
my-vue-app/
73+
├── public/
74+
│ ├── favicon.ico
75+
│ └── ...
76+
├── src/
77+
│ ├── assets/
78+
│ │ └── logo.png
79+
│ ├── components/
80+
│ │ └── HelloWorld.vue
81+
│ ├── views/
82+
│ │ └── Home.vue
83+
│ ├── App.vue
84+
│ ├── main.js
85+
│ └── router.js
86+
├── .gitignore
87+
├── index.html
88+
├── package.json
89+
├── README.md
90+
└── vite.config.js
91+
```
92+
93+
## 🛫 How to deploy to GitHub Pages
94+
95+
Deploying to github pages is totally up to you, be it through **[GitHub Actions](https://docs.github.com/en/actions/deployment/about-deployments/deploying-with-github-actions)**, or via **[gh-pages](https://www.npmjs.com/package/gh-pages)** package, or manually.
96+
97+
> [!NOTE]
98+
>
99+
> Also take note that [GitHub Pages](https://pages.github.com/) have limitations, it's free, yes, but it has a limit.
100+
101+
### ❗ via package ❗
102+
103+
**1. Install `gh-pages` package.**
104+
105+
```bash
106+
npm install gh-pages --save-dev
107+
```
108+
109+
**2. Add base path to your repo in `vite.config.js`.**
110+
111+
```js
112+
// vite.config.js
113+
import { defineConfig } from 'vite';
114+
import vue from '@vitejs/plugin-vue';
115+
116+
// https://vitejs.dev/config/
117+
export default defineConfig({
118+
plugins: [vue()],
119+
base: '/vue', // repo-name
120+
});
121+
```
122+
123+
**3. Add `deploy` to your scripts.**
124+
125+
```json
126+
{
127+
"scripts": {
128+
"deploy": "npm run build && gh-pages -d dist"
129+
}
130+
}
131+
```
132+
133+
**4. Create and configure a new branch for `gh-pages`.**
134+
135+
> [!IMPORTANT]
136+
>
137+
> Make sure that you have committed your changes before doing this. All untracked and staged files may be deleted.
138+
139+
I like to do this manually. If there is some automated way, feel free to let me know by any means.
140+
141+
```bash
142+
git checkout --orphan gh-pages
143+
git reset --hard
144+
git commit --allow-empty -m 'commit_message'
145+
git push origin gh-pages
146+
```
147+
148+
**5. Publish the production build.**
149+
150+
```bash
151+
npm run deploy
152+
```
153+
154+
### ❗ via manually configuring github pages settings ❗
155+
156+
**1. Create your project.**
157+
Start coding your project, either use a framework like React, Vue, or not.
158+
159+
**2. Publish production build to GitHub.**
160+
Push your _production build_ to your github repo. After that, check if your `index.html` file is uploaded, since it is one of the core files needed for your website to work.
161+
162+
**3. Configure your GitHub Pages on repo Settings.**
163+
Navigate to `Settings > Pages > Build and deployment`. Make sure the **Source** says 'Deploy from a branch', and then configure the **Branch** settings and change it to your branch with the files.
164+
165+
---
166+
167+
🌎 [kerbethecoder](https://kerbethecoder.com/)
168+
📫 krby.cnts@gmail.com
169+
📌 July 31, 2024

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy