A bare-bones vite + react + typescript starter template with eslint + prettier, vitest + @testing-library and react-router
The Vite + React + TypeScript Starter is a setup that combines Vite, React, and TypeScript to provide a streamlined development environment for creating web applications. With this setup, developers can benefit from the fast, modern build tooling provided by Vite, the power and flexibility of React, and the type safety of TypeScript.
To set up the Vite + React + TypeScript Starter, follow these steps:
mkdir my-app
cd my-app
npm init -y
# or
yarn init -y
npm install --save-dev vite eslint typescript eslint-airbnb-config prettier vitest jsdom @testing-library/react react-router
# or
yarn add --dev vite eslint typescript eslint-airbnb-config prettier vitest jsdom @testing-library/react react-router
vite.config.js file in the project root and add the following content:module.exports = {
root: "./src",
build: {
outDir: "../dist",
rollupOptions: {
input: "/main.tsx",
},
},
};
tsconfig.json file in the project root and add the following content:{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"jsx": "react",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"exclude": ["node_modules"]
}
.eslintrc file in the project root and add the following content:{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"airbnb",
"prettier"
],
"plugins": ["react"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"es6": true,
"node": true
},
"rules": {
"react/prop-types": "off"
}
}
.prettierrc file in the project root and add the following content:{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100
}
src directory and use the Vite development server to preview your changes.The Vite + React + TypeScript Starter provides developers with a powerful and efficient setup for creating web applications. By combining Vite, React, TypeScript, and various other tools and libraries, this setup offers fast builds, type safety, linting, testing, and routing capabilities. With a straightforward installation process, developers can quickly set up their development environment and start building modern and maintainable web applications.