Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Environment Setup

Environment Setup

We will use Vite to quickly scaffold the TaskHub project; for Vite details, refer to:Vite Tutorial.

1. Create the Project

Open the terminal and run the following command to create a Vite + Vue 3 project (choose the Script Setup syntax):



# npm 命令

npm create vite@latest task-hub -- --template vue



# yarn 命令

yarn create vite task-hub --template vue



# pnpm command (recommended, faster)

pnpm create vite task-hub -- --template vue

After successful execution, the output is as follows:

After a successful start, visit the local address shown in the terminal (default http://localhost:5173/) to see the Vue 3 initial page.

  1. Project Directory

We can enter the directory:

cd task-hub

If VS Code is installed, you can use VS Code's code command to open the directory; for VS Code details, refer to:VS Code Tutorial.



code .

The directory structure after startup is as follows:

Other related commands:

# 安装依赖

npm install



# 启动

npm run dev

# Clean default code

2. Clean Up Default Code

Delete src/components/HelloWorld.vue.

Empty src/style.css.

Modify src/App.vue with the following code:

Example

Introduce Tailwind CSS

Install and configure the atomic CSS framework.

npm install tailwindcss @tailwindcss/vite

Modify vite.config.js:

Example

import

{

defineConfig

}

from

'vite'

import

vue from

'@vitejs/plugin-vue'

import

tailwindcss from

'@tailwindcss/vite'

import

path from

'path'

export

default

defineConfig

(

{

  plugins

:

[

    vue

(

)

,

    tailwindcss

(

)

,

// activate the Tailwind v4 engine

 

]

,

  resolve

:

{

    alias

:

{

     

'@'

:

path.

resolve

(

__dirname

,

'./src'

)

,

// configure path alias

   

}

,

 

}

,

}

)

In v4, Tailwind runs as a Vite plugin and automatically scans your .vue files.

In src/style.css, import:

In Tailwind v4, all configuration (theme, variables) is written directly in CSS. Reset src/style.css as follows:

Example

@import "tailwindcss";

/* v4 way of defining theme variables */

@theme {

  --color-brand

:

#3b82f6

;

  --radius-xl

:

1rem

;

}

/* global base styles */

@layer base {

  body

{

   

@apply bg-slate-50 text-slate-900 antialiased;

 

}

}