Skip to content

Boilerplate for a Vite based React app. It comes with all the tools and configuration you need to start developing right away, automatically preventing errors and adhering to conventions and best practices.

License

Notifications You must be signed in to change notification settings

drdla/vite-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vite Boilerplate

This is a boilerplate setup for a Vite based React app.

It comes with all the tools and configuration you need to start developing right away, automatically preventing errors and adhering to conventions and best practices.

Tech Stack

App

The actual app only comes with a minimal setup, to cater to the individual needs of the project:

Build / Dev Tools

Testing

  • Vitest for unit tests; files matching .test. are run with Vitest and the test package script (config)
  • Playwright for end-to-end tests; files matching .spec. are run with Playwright and the test:e2e package script (config)
  • Storybook for component tests (config)
  • istanbul/nyc for code coverage reports

Folder Structure

  • public: files publicly accessible through the browser
    • locales: translation files, organized by language
  • src: application source code
    • assets: images, SVGs, etc.
    • components: UI components, organized according to Atomic Design principles
      • atoms: foundational building blocks w/o dependencies
      • molecules: groups of components including other components
      • organisms: pieces of functionality built from groups of components
      • templates: page-level objects that place components into a layout
    • constants: constant values
    • modules: self-contained pieces of functionality
    • stories: Storybook story definitions
    • styles: theme and styles
    • typings: TypeScript type definitions and modules
    • utils: reusable functions and libraries, e.g. for string manipulation, internationalization, working with arrays, etc.
  • e2e-tests: end-to-end tests (unit tests are co-located with the corresponding files)

Installation

This repo provides a Dev Container to enable developing in a fully pre-set up and isolated environment.

Prerequisites: To use Dev Containers, you need to have Docker and the VSCode extension for Dev Containers set up.

When you open the project in VSCode, it will show a popup informing you that the "Folder contains a Dev Container". Click the "Reopen in container" button to start the container and open the folder in the container with VSCode configured and all recommended plugins installed. It will also install all required dependencies for you.

When you open the container for the first time, the container needs to build, which might take a little time. Once it has been built, starting the container is almost instant.

If you don't want to work with the Dev Container, you need to install the dependencies with yarn install after checking out the repo.

Usage

Starting the Devserver

Start the Vite devserver with

yarn dev

You can then open the application on http://localhost:5173 in your browser.

Building the App

Create a production build of the app with

yarn build

You can run the production build locally with

yarn preview

Package Scripts

Some package scripts are run automatically or as components of other package scripts.

The scripts you will typically use are

  • dev: start the devserver to run the app locally
  • check-npm-packages: check for packages not listed in the package.json, unused packages, and available updates
  • format: lint and format the codebase
  • i18n: extract translation keys
  • lint: lint the codebase (component of format script)
  • lint:styles: lint the CSS of the codebase
  • storybook: start storybook
  • test: run all tests
  • test:coverage: generate test coverage report for unit/component/integration tests
  • test:e2e: run end-to-end tests (headless)
  • test:e2e:coverage: generate test coverage report for end-to-end tests
  • test:e2e:ui: run end-to-end tests with user interface (for writing and debugging end-to-end test)

About

Boilerplate for a Vite based React app. It comes with all the tools and configuration you need to start developing right away, automatically preventing errors and adhering to conventions and best practices.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published