Fix Vite config

Node plugin would also work on build which messes up the `root` config
entry. This should fix the deploy not working.
This commit is contained in:
Nikita Karamov 2023-03-16 13:00:18 +01:00
parent 3d528cc4e4
commit c53384a54d
No known key found for this signature in database
GPG key ID: 41D6F71EE78E77CD

View file

@ -1,24 +1,24 @@
import legacy from "@vitejs/plugin-legacy"; import legacy from "@vitejs/plugin-legacy";
import { VitePluginNode } from "vite-plugin-node"; 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 { export default {
build: { build: {
minify: "terser", minify: "terser",
terserOptions: { ecma: 5 }, terserOptions: { ecma: 5 },
sourcemap: "true", sourcemap: "true",
}, },
plugins: [ plugins: [legacy(), ...vitePluginNode],
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",
}),
],
}; };