Skip to content

Instantly share code, notes, and snippets.

@duanyrf
Last active February 14, 2023 13:39
Show Gist options
  • Save duanyrf/bbb3cf63ecae84030ef8bf92ba8de966 to your computer and use it in GitHub Desktop.
Save duanyrf/bbb3cf63ecae84030ef8bf92ba8de966 to your computer and use it in GitHub Desktop.

Create React and Typescript project with Vite

pnpm create vite;

Choose react + Typescript + SWC template project.

Install and configure tailwindcss

  1. install dependencies with pnpm add -D tailwindcss postcss autoprefixer;

  2. Generate both tailwind.config.cjs and postcss.config.cjs with pnpm exec tailwindcss init -p;

  3. Configure your template paths in tailwind.config.cjs file:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

To add customized colors to tailwindcss pallete, use extend option above. Follow the example:

  ...
  theme: {
    extend: {
      colors: {
        backgroung: '#09090A',
      },
    },
  },
  ...
  1. Add the Tailwind directives to your CSS global file @tailwind base; @tailwind components; @tailwind utilities;

  2. Done! Start using Tailwind in your project.

Install and configure ESLint by @rocketseat

  1. Install dependencies with pnpm add -D eslint @rocketseat/eslint-config;

  2. Create a file called .eslintrc.json at root dir and put this on it:

{
  "extends": "@rocketseat/eslint-config/react"
}
  1. Add the following script in package.json:
 "scripts": {
    ...
    "lint": "eslint src --ext .ts,.tsx"
  },
  ...

To check ESLint problems run pnpm lint, and add --fix to fix them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment