Initializing React Project with Vite

Create a New Project

export VITE_PROJECT="vite-project"
yarn create vite -t react --no-interactive "$VITE_PROJECT"
Cleanup Vite Project Template
yarn install --immutable --immutable-cache
yarn remove @types/react @types/react-dom
yarn remove eslint eslint-plugin-react-hooks eslint-plugin-react-refresh globals @eslint/js
rm eslint.config.js
sed -i 's@/src/main.jsx@/app/main.jsx@' index.html
mv src app
Use Latest Version of Yarn

yarn set version stable
yarn install
Enable Node Modules Linking with Local Cache
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: 0BSD
enableGlobalCache: false
enableTelemetry: false
nodeLinker: node-modules
.yarn/*
!.yarn/cache/
!.yarn/releases/
yarn-debug.log*
yarn-error.log*
/node_modules/
Unify Chores via Makefile
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: 0BSD
DISTNAME := $(shell jq -r .name package.json)
VERSION := $(shell jq -r .version package.json)
DISTDIR := dist
HOST := 127.27.0.1
PORT := 5173
.PHONY: dev
dev:
yarn dev --host="$(HOST)" --port="$(PORT)"
.PHONY: install
install:
yarn install --immutable --immutable-cache
.PHONY: update
update:
yarn up
.PHONY: build
build:
yarn build --outDir="$(DISTDIR)"
.PHONY: dist
dist: build
tar --directory="$(DISTDIR)" --create --xz --file="$(DISTNAME)-$(VERSION).tar.xz" .
.PHONY: test
test:
yarn test
.PHONY: clean
clean:
-rm --recursive "$(DISTDIR)"
-rm "$(DISTNAME)-$(VERSION).tar.xz"
.PHONY: distclean
distclean: clean
git clean --force -Xd