Skip to content

Commit b7c7a51

Browse files
committed
Implemented basic introduction to ViteJS
1 parent 03233f9 commit b7c7a51

File tree

2 files changed

+114
-4
lines changed

2 files changed

+114
-4
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ This repository contains a collection of examples that provide hands-on learning
3131
1. Basic Usage of JavaScript
3232
2. Basic Usage of TypeScript
3333
3. Using React with TypeScript
34-
4. TailwindCSS with React
34+
4. Using TailwindCSS with React
35+
5. Basic Usage of ViteJS
3536

3637
In the end you will be able to create a React application with TypeScript and TailwindCSS like this: [Example App](https://github.com/MemerGamer/vite-react-ts-tailwind-example)
3738

38-
**Note**: In the example app we also use [ViteJS](https://vitejs.dev/) which is not covered in this quickstart guide.
39-
In summary ViteJS is frontend tool that is used for building fast and optimized web applications. It uses a modern build system and a fast development server to provide a streamlined and efficient development experience.
40-
4139
## Getting Started
4240

4341
- [Getting Started with JavaScript](./JavaScript.md)
4442
- [Getting Started with TypeScript](./TypeScript.md)
4543
- [Getting Started with React and TypeScript](./React.md)
4644
- [Getting Started with TailwindCSS](./TailwindCSS.md)
45+
- [Getting Started with ViteJS](./ViteJS.md)

ViteJS.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Getting Started with ViteJS
2+
3+
ViteJS is a next-generation development build tool that offers a highly optimized and lightning-fast development experience for modern web applications. It focuses on instant server startup, fast hot module replacement (HMR), and quick builds. This guide will walk you through the basics of getting started with ViteJS and help you set up your first project.
4+
5+
## Table of Contents
6+
7+
- [Getting Started with ViteJS](#getting-started-with-vitejs)
8+
- [Table of Contents](#table-of-contents)
9+
- [Pre-requisites](#pre-requisites)
10+
- [Creating a New Project](#creating-a-new-project)
11+
- [Development Server](#development-server)
12+
- [Building for Production](#building-for-production)
13+
- [Using Plugins](#using-plugins)
14+
- [Adding Frameworks](#adding-frameworks)
15+
- [Conclusion](#conclusion)
16+
17+
## Pre-requisites
18+
19+
To get started with ViteJS, make sure you have Node.js installed on your machine. You can check if Node.js is installed by running the following command in your terminal:
20+
21+
```bash
22+
node -v
23+
```
24+
25+
If Node.js is not installed, you can download and install it from the official Node.js website (https://nodejs.org).
26+
27+
## Creating a New Project
28+
29+
To create a new Vite project, you can use the `create-vite` command-line utility. This utility is included with the Vite package, so you can run it using the `npx` command:
30+
31+
```bash
32+
npm create vite@latest my-project --template <template-name>
33+
```
34+
35+
Replace `<template-name>` with the desired template you want to use.Vite will automatically scaffold a basic project structure for you.
36+
37+
Supported templates include:
38+
39+
| JavaScript | TypeScript |
40+
| ---------- | ---------- |
41+
| vanilla | vanilla-ts |
42+
| vue | vue-ts |
43+
| react | react-ts |
44+
| preact | preact-ts |
45+
| lit | lit-ts |
46+
| svelte | svelte-ts |
47+
48+
Navigate into the project directory:
49+
50+
```bash
51+
cd my-project
52+
```
53+
54+
## Development Server
55+
56+
Vite comes with a built-in development server that provides fast, hot module replacement (HMR) for a seamless development experience. To start the development server, run the following command:
57+
58+
```bash
59+
npm run dev
60+
```
61+
62+
This will start the development server and open your project in the default browser. Any changes you make to your code will be instantly reflected in the browser without a full page reload.
63+
64+
## Building for Production
65+
66+
When you're ready to build your Vite project for production, you can use the following command:
67+
68+
```bash
69+
npm run build
70+
```
71+
72+
This command will generate an optimized production-ready build of your project.
73+
74+
## Using Plugins
75+
76+
Vite supports various plugins that can extend its functionality and integrate with different tools and frameworks. You can add plugins to your Vite project by installing them as dependencies and configuring them in the `vite.config.js` file.
77+
78+
For example, to add the TypeScript plugin, you can run the following command:
79+
80+
```bash
81+
npm install --save-dev vite-plugin-typescript
82+
```
83+
84+
Then, update your `vite.config.js` file to include the plugin:
85+
86+
```javascript
87+
import { defineConfig } from "vite";
88+
import ts from "vite-plugin-typescript";
89+
90+
export default defineConfig({
91+
plugins: [ts()],
92+
});
93+
```
94+
95+
## Adding Frameworks
96+
97+
Vite works seamlessly with popular JavaScript frameworks and libraries, such as React, Vue.js, and Preact. You can create a new Vite project with a specific framework template by specifying it during project creation.
98+
99+
For example, to create a Vite project with the React template, you can run the following command:
100+
101+
```bash
102+
npm create vite@latest my-react-project --template react
103+
```
104+
105+
This will set up a new Vite project pre-configured with React.
106+
107+
## Conclusion
108+
109+
ViteJS provides an optimized and efficient development experience for modern web applications. Its fast startup time, hot module replacement, and quick build process make
110+
111+
it an excellent choice for building high-performance projects. This guide covered the basics of getting started with ViteJS, including installation, project creation, using the development server, building for production, using plugins, and adding frameworks. With ViteJS, you can streamline your web development workflow and create fast, modern web applications with ease.

0 commit comments

Comments
 (0)