
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
vite-plugin-node
Advanced tools
Note: this plugin is still under active development
A vite plugin to allow you to use vite as node dev server.
Install vite and this plugin with your favourite package manager, here use npm as example:
$ npm install vite vite-plugin-node -D
Create a vite.config.js
file in your project root to config vite to actually use this plugin:
import { VitePluginNode } from 'vite-plugin-node';
/**
* @type {import('vite').UserConfig}
*/
const config = {
// ...
plugins: [
VitePluginNode({
// the node framework yout are using,
// currently this plugin support 'express', 'nest' and 'custom',
// more framework support incoming!
// when set this to 'custom', you have to the createCustomServer option // to tell the plugin how to create/start/... your node server
server: 'express',
// tell the plugin where is your project entry
appPath: './app.ts',
// the port you want the server to run on
port: 3000,
// Optional, the TypeScript compiler you want to use
// by default this plugin is using vite default ts compiler which is esbuild
// 'swc' compiler is supported to use as well for frameworks
// like Nestjs (esbuild dont support 'emitDecoratorMetadata' yet)
tsCompiler: 'esbuild',
// Required field when set server option to 'custom'
// For examples, check out './src/servers' folder
createCustomServer: () => IServer
})
]
}
export default config;
Update your server entry to export your app named createViteNodeApp
const app = express();
// your beautiful code...
if (process.env.NODE_ENV === 'production') {
app.listen(3000)
}
export const createViteNodeApp = app;
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
if (process.env.NODE_ENV === 'production') {
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
}
export const createViteNodeApp = NestFactory.create(AppModule);
Add a npm script to run the dev server:
"scripts": {
"dev": "vite-node"
},
Run the script! npm run dev
As this plugin just fresh developed, there are still lots ideas need to be implemented, including:
Create an issue if you found any bugs to helpe me to improve this project
FAQs
Vite plugin to enable your node server HMR
The npm package vite-plugin-node receives a total of 30,070 weekly downloads. As such, vite-plugin-node popularity was classified as popular.
We found that vite-plugin-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.