- ESLint
- Prettier - Code formatter
- EditorConfig for VS code
- Tailwind CSS IntelliSense
- Code Spell Checker
- GitLens - Git supercharged
npm create vite@latest app-name -- --template react-ts
To change port on which application will start edit vite.config.ts
with:
server: {
port: 3000,
},
eslint --init
npm install --save-dev eslint-config-prettier
then add "prettier" as the last item in the extends array
{
"extends": ["some-other-config-you-use", "prettier"]
}
To get rid of the error 'module' is not defined. (eslintno-undef) in .js files, it is necessary to add "node": true
to env section of eslintrc.json file
{
"env": {
"browser": true,
"es2021": true,
"node": true
}
}
for more details see: eslint-config-prettier
Adding file .prettierrc with following content will inherit some configuration from .editorconfig file
{
"editorconfig": true
}
Option | .prettierrc | .editorconfig | Default Prettier value |
---|---|---|---|
Print Width | printWidth | max_line_length | 80 |
Tab Width | tabWidth | indent_size | 2 |
Tabs | useTabs | indent_style | false |
End of Line | endOfLine | end_of_line | "lf" |
For the complete list of Prettier options, see: Prettier Config Options
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
@tailwind base;
@tailwind components;
@tailwind utilities;
npm install -D prettier prettier-plugin-tailwindcss
- Environment variables are exposed on import.meta.env object
- For variables loaded from the .env files, only ones that are prefixed with VITE_ are available on the client side.
To provide type support edit vite-env.d.ts
file, adding variable definitions in ImportMetaEnv
interface
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_APP_TITLE: string;
// more env variables...
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}
For more details see: Vite Environment Variables
To enable alias imports it is necessary to configure resolve property in vite.config.ts
resolve: {
alias: [{ find: "@", replacement: path.resolve(__dirname, "src") }],
},
Install @types/node as dev dependency to get rid of type errors for path
It is also necessary to edit tsconfig.json
(Set baseUrl and add path alias).
"paths": {
"@/*": ["./*"]
},
"baseUrl": "./src"
Initialize Storybook by running the following command:
npx sb init
To open Storybook run:
npm run storybook
If the type
property in package.json
is set to module
, it will be necessary to rename file .storybook/main.js
to ./storybook/main.cjs
(CommonJS), for the Storybook to be able to run.
To load Tailwind styles add the following line at the top of the ./storybook/preview.js
file:
import "../src/index.css";
npm i @tanstack/react-query
npm i @tanstack/react-query-devtools