From c53384a54d891999ba9bef54c3a451fbf92e99c1 Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Thu, 16 Mar 2023 13:00:18 +0100 Subject: [PATCH] Fix Vite config Node plugin would also work on build which messes up the `root` config entry. This should fix the deploy not working. --- vite.config.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/vite.config.js b/vite.config.js index 2242930..d99ae09 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,24 +1,24 @@ import legacy from "@vitejs/plugin-legacy"; import { VitePluginNode } from "vite-plugin-node"; +const vitePluginNode = VitePluginNode({ + // Workaround from: https://github.com/axe-me/vite-plugin-node/issues/47 + adapter({ app, req, res, next }) { + if (req.url.startsWith("/api/")) { + app(req, res); + } else { + next(); + } + }, + appPath: "./api/share.js", +}); +vitePluginNode[0].apply = "serve"; + export default { build: { minify: "terser", terserOptions: { ecma: 5 }, sourcemap: "true", }, - plugins: [ - legacy(), - VitePluginNode({ - // Workaround from: https://github.com/axe-me/vite-plugin-node/issues/47 - adapter({ app, req, res, next }) { - if (req.url.startsWith("/api/")) { - app(req, res); - } else { - next(); - } - }, - appPath: "./api/share.js", - }), - ], + plugins: [legacy(), ...vitePluginNode], };