Vite starter template with React and Typescript. It provides a solid foundation for building web applications using modern technologies. This template includes support for environment variables, allowing easy configuration of your project. It also leverages Sass for styling, making it convenient to create visually appealing designs.
To start the development server, run the following command npm run dev
To build the project, run the following command npm run build
To preview the built project, run the following command npm run preview
Vite supports environment variables by creating a .env file in the project's root directory. Add environment variables starting with VITE_ to this file. For example VITE_API_KEY=123456789
You can access environment variables in your code using import.meta.env. For example:
const Header = () => {
return <div>{import.meta.env.VITE_API_KEY}</div>;
};
export default Header;Sass support is built into Vite. We can use it by installing the sass package. npm install sass
Create a styles folder and add main.scss file.
body {
background-color: steelblue;
}Import Sass file into the app.jsx file.
import './styles/main.scss';The project structure is organized as follows:
.github: GitHub-related filespublic: Public assetssrc: Source code.gitignore: Git ignore rulesREADME.md: Project documentationindex.html: HTML templatepackage-lock.json: Lock file for npm dependenciespackage.json: Project configuration and dependenciestsconfig.json: TypeScript configurationtsconfig.node.json: TypeScript configuration for Node.jsvite.config.ts: Vite configuration
This project is licensed under the MIT License.