🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

vite3-plugin-express

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite3-plugin-express

A vite plugin that hot reloads a node express server

0.1.10
latest
Source
npm
Version published
Weekly downloads
565
-27.1%
Maintainers
0
Weekly downloads
 
Created
Source

vite3-plugin-express

A simple plugin for express that runs an express node js server from within vite

How to use:

In vite.config.ts

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import express from "vite3-plugin-express"

export default defineConfig({
  plugins: [vue(), express('express-server.ts')]
})

example express app file express-server.ts

import express from "express"; 

export const app = express(); // the express handler should be exported as app

if (!process.env['VITE']) // When running from `vite` there is no need to call `app.listen`
  app.listen(3002, () => console.log("Started"));
  • Make sure that the express handler is exported as app

  • Make sure not to call app.listen.

    The plugin adds the VITE environment variable, use that to disable the call to app.listen

FAQs

Package last updated on 22 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts