A minimal and lightweight starter template for React with TypeScript and SCSS using Vite. This template provides a clean setup without unnecessary boilerplate, so you can start your project quickly.
- ⚡ Fast development with Vite
- 🛠️ Type safety with TypeScript
- ⚛️ React with modern JSX
- ✅ ESLint for code quality
- 🎨 SCSS support with
sass-embedded - 🖼️ SVG import support using
vite-plugin-svgr - 🔥 Aliases (
@/→/src) for cleaner imports - 🌍 Default development server runs on
localhost:3000
First, clone this repository:
git clone https://github.com/miftawidaya/vite-minimal-react-ts-scssThen, install the dependencies:
npm installStart the development server:
npm run devBuild for production:
npm run buildPreview the production build:
npm run previewRun ESLint to check code quality:
npm run lintClean and reinstall dependencies:
npm run clean # Removes node_modules & dist, then reinstalls dependenciesCheck for outdated dependencies:
npm outdatedUpdate dependencies to the latest compatible versions:
npm updateUpgrade all dependencies to their latest versions (including breaking changes):
npx npm-check-updates -u
npm install@vitejs/plugin-react: Enables React fast refresh and optimizations.vite-plugin-svgr: Allows importing.svgfiles as React components.
With vite-plugin-svgr, you can import .svg files like this:
import LogoIcon from '@/assets/logo.svg';
function App() {
return <LogoIcon width={12} height={12} />;
}
export default App;Use @/ instead of long relative paths, e.g.:
import Component from '@/components/Component';Defined in vite.config.ts:
resolve: {
alias: {
'@': '/src',
},
},Global SCSS variables and mixins are available from @/scss/_shared.scss.
You can use them directly in .scss files.
The dev server runs on http://localhost:3000 by default.
You can change the port in vite.config.ts:
server: {
port: 3000,
},This project includes a fully configured ESLint setup with the following features:
react: Linting rules for React.react-hooks: Ensures proper usage of React Hooks.react-refresh: Supports React Fast Refresh.import: Validates module imports.
- ✅
react/react-in-jsx-scopeis disabled (not needed with Vite). - ✅
react-refresh/only-export-componentswarns when exporting non-component values. - ✅
import/no-unresolvedensures all imports exist. - ✅
react/prop-typesis disabled since TypeScript handles prop validation.
For larger projects, enable type-aware linting:
- Update
eslint.config.ts:
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
});-
Use stricter linting:
- Replace
tseslint.configs.recommendedwithtseslint.configs.recommendedTypeCheckedortseslint.configs.strictTypeChecked. - Optionally add
...tseslint.configs.stylisticTypeChecked.
- Replace
-
Install & configure
eslint-plugin-react:
npm install eslint-plugin-react --save-devUpdate eslint.config.ts:
// eslint.config.js
import react from 'eslint-plugin-react';
export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
});