Fastify boilerplate with Vite & Vitest
Enhance your Fastify DX with the power of Vite & Vitest.
Features
-
⚡ All the power of Vite (Next GenerationFrontendIsomorphic Tooling):- Lightning fast HMR (hot module replacement) in dev mode with Vite Plugin Node.
- Smart & instant watch mode, like HMR for tests with Vitest.
-
🛠️ DX setup:- Vite, Prettier and Typescript with common config, esnext ready and alias
@/*
- Tests with one Fastify instance setup, code coverage
- Fastify with logger
- Production build without Vite
- Vite, Prettier and Typescript with common config, esnext ready and alias
So, it's super fast donc ça va super vite
Why and How
See Why and How Vite in node and Why Vitest.
Get started
- Clone this repo or use tiged with:
degit https://github.com/ManUtopiK/vite-fastify-boilerplate
- Install:
pnpm install
Start dev mode using Vite:
pnpm dev
Start test mode using Vitest:
pnpm test
Start test mode with coverage:
pnpm coverage
Compile typescript to javascript:
pnpm build
Start for production:
pnpm start
Code
- Main file:
src/app.ts
- Configure logger:
src/logger.ts
- Change port in
.env
Docs
Ressources
Add vite plugin example
.gql
and .graphql
files
Import -
Install packages:
pnpm add graphql graphql-tag pnpm add -D vite-plugin-simple-gql
-
Configure
vite.config.ts
:import gql from 'vite-plugin-simple-gql'
And add
gql()
toplugins
:plugins: [gql(), ...]
Now you can import your graphql files in your code:
// example.ts
import MyQuery from './MyQuery.gql'
Contributions
If you would like to make any contribution you are welcome to do so.
Bugs
Please create an issue if you found any bugs, to help me improve this project!