vite-plugin-node
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -15,3 +15,3 @@ /// <reference types="express" /> | ||
}; | ||
export declare const getPluginConfig: (server: ViteDevServer) => VitePluginNodeConfig; | ||
export declare const createMiddleware: (server: ViteDevServer) => Connect.HandleFunction; | ||
export declare const getPluginConfig: (server: ViteDevServer) => Promise<VitePluginNodeConfig>; | ||
export declare const createMiddleware: (server: ViteDevServer) => Promise<Connect.HandleFunction>; |
@@ -24,10 +24,12 @@ "use strict"; | ||
}; | ||
const getPluginConfig = (server) => { | ||
const env = { command: 'serve', mode: '' }; | ||
const getPluginConfig = async (server) => { | ||
const plugin = server.config.plugins.find(p => p.name === __1.PLUGIN_NAME); | ||
if (!plugin) { | ||
console.error('Please setup VitePluginNode in your vite.config.js first'); | ||
(0, process_1.exit)(1); | ||
} | ||
return plugin.config({}, { command: 'serve', mode: '' }) | ||
.VitePluginNodeConfig; | ||
let userConfig; | ||
if (typeof plugin.config === 'function') | ||
userConfig = await plugin.config({}, env); | ||
if (userConfig) | ||
return userConfig.VitePluginNodeConfig; | ||
console.error('Please setup VitePluginNode in your vite.config.js first'); | ||
(0, process_1.exit)(1); | ||
}; | ||
@@ -43,4 +45,4 @@ exports.getPluginConfig = getPluginConfig; | ||
}; | ||
const createMiddleware = (server) => { | ||
const config = (0, exports.getPluginConfig)(server); | ||
const createMiddleware = async (server) => { | ||
const config = await (0, exports.getPluginConfig)(server); | ||
const logger = server.config.logger; | ||
@@ -47,0 +49,0 @@ const requestHandler = getRequestHandler(config.adapter); |
@@ -64,4 +64,4 @@ "use strict"; | ||
}, | ||
configureServer: (server) => { | ||
server.middlewares.use((0, server_1.createMiddleware)(server)); | ||
configureServer: async (server) => { | ||
server.middlewares.use(await (0, server_1.createMiddleware)(server)); | ||
}, | ||
@@ -68,0 +68,0 @@ }, |
{ | ||
"name": "vite-plugin-node", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Vite plugin to enable your node server HMR", | ||
@@ -31,3 +31,4 @@ "author": "Axe", | ||
"peerDependencies": { | ||
"vite": "^3.0.0" | ||
"@swc/core": "^1.2.153", | ||
"vite": "^4.0.0" | ||
}, | ||
@@ -57,3 +58,3 @@ "peerDependenciesMeta": { | ||
"rxjs": "^7.5.5", | ||
"vite": "^2.9.8" | ||
"vite": "^4.0.0" | ||
}, | ||
@@ -60,0 +61,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26347
384
5