Skip to content

mvromer/wds-use-vite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vite Middleware for Web Dev Server

A middleware for Web Dev Server (WDS) and Web Test Runner (WTR) that allows requests to be transformed and served using Vite. Rather than starting Vite's dev server alongside WDS/WTR and proxying requests to it, this will install Vite as a middleware component inside the WDS/WTR request pipeline.

Compatible with Vite 3, 4, 5, and 6.

Installation

npm install --save-dev wds-use-vite

Configuration

This package exports two functions

  • addVite – Creates a WDS/WTR plugin that is responsible for starting Vite in middleware mode when WDS/WTR starts.
  • useVite – Defines a WDS/WTR middleware function that inspects the current request and determines if it should allow the Vite middleware to process it or not.

You must configure both in order for the Vite middleware to work as intended. To do so, modify your WDS/WTR config as follows:

import { addVite, useVite } from 'wds-use-vite';

export default {
  plugins: [addVite()],
  middleware: [useVite()],
  // ... rest of config here ...
};

About

Web Dev Server middleware that uses Vite to transform and serve requests

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors