Giter Club home page Giter Club logo

devtoolbox's Introduction

image

Static Badge Static Badge

"Vue 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."

This guide provides a first-hand experience on building a Vue project using Vite + Tailwind CSS and deploying it on GitHub Pages.

๐Ÿ› ๏ธ Installation

1. Create your project. You can use the official guide or use Vite like this.

# terminal
npm create vite@latest project_name -- --template vue
cd project_name

2. Install Tailwind CSS.

# terminal
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

3. Configure template paths.

// tailwind.config.js
/** @type {import('tailwindcss').Config} */
export default {
  content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
  theme: {
    extend: {},
  },
  plugins: [],
};

4. Add the Tailwind directives.

/* ./src/style.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

5. Start your build process.

# terminal
npm run dev

6. Happy coding. ^^

<!-- App.vue -->
<template>
  <h1 class="text-3xl font-bold underline">Hello world!</h1>
</template>

๐Ÿ—‚๏ธ File Structure

Sample project structure.

my-vue-app/
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ assets/
โ”‚   โ”‚   โ””โ”€โ”€ logo.png
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ””โ”€โ”€ HelloWorld.vue
โ”‚   โ”œโ”€โ”€ views/
โ”‚   โ”‚   โ””โ”€โ”€ Home.vue
โ”‚   โ”œโ”€โ”€ App.vue
โ”‚   โ”œโ”€โ”€ main.js
โ”‚   โ””โ”€โ”€ router.js
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ vite.config.js

๐Ÿ›ซ How to deploy to GitHub Pages

Deploying to github pages is totally up to you, be it through GitHub Actions, or via gh-pages package, or manually.

Note

Also take note that GitHub Pages have limitations, it's free, yes, but it has a limit.

โ— via package โ—

1. Install gh-pages package.

npm install gh-pages --save-dev

2. Add base path to your repo in vite.config.js.

// vite.config.js
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  base: '/vue', // repo-name
});

3. Add deploy to your scripts.

{
  "scripts": {
    "deploy": "npm run build && gh-pages -d dist"
  }
}

4. Create and configure a new branch for gh-pages.

Important

Make sure that you have committed your changes before doing this. All untracked and staged files may be deleted.

I like to do this manually. If there is some automated way, feel free to let me know by any means.

git checkout --orphan gh-pages
git reset --hard
git commit --allow-empty -m 'commit_message'
git push origin gh-pages

5. Publish the production build.

npm run deploy

โ— via manually configuring github pages settings โ—

1. Create your project. Start coding your project, either use a framework like React, Vue, or not.

2. Publish production build to GitHub. 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.

3. Configure your GitHub Pages on repo Settings. 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.


๐ŸŒŽ kerbethecoder
๐Ÿ“ซ [email protected]
๐Ÿ“Œ July 31, 2024

devtoolbox's People

Contributors

kerbethecoder avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.