Build and deployment errors on Fly.io when using the plugin
kiliman opened this issue · 3 comments
Hi @kiliman, I'm having issues with deployment to Fly.io when using your package after following the instructions of setup in github.
Initially, I got the error that remix-express-vite-plugin was not found. I've moved it from dev dependencies to dependencies and it worked.
Now the issue is "cannot find module "/app/node_modules/remix-express-vite-plugin/build/server/remix.js" imported from /app/node_modules/remix-express-vite-plugin/dist/express.js
Any ideas how to solve it? 🙂
Thank you in advance
https://discord.com/channels/770287896669978684/1225540482378104912/1225579287399108678
Hi there,
I'm adding the logs of Fly and my vite config, they may be useful.
fly logs
2024-04-04T22:44:50Z proxy[781117ef1d5478] mad [info]Starting machine 2024-04-04T22:44:50Z app[781117ef1d5478] mad [info]Express server listening at http://localhost:3000 2024-04-04T22:45:00Z app[781117ef1d5478] mad [info]Error: Cannot find module '/app/node_modules/remix-express-vite-plugin/build/server/remix.js' imported from /app/node_modules/remix-express-vite-plugin/dist/express.js 2024-04-04T22:45:00Z app[781117ef1d5478] mad [info] at moduleResolve (node:internal/modules/esm/resolve:917:10) 2024-04-04T22:45:00Z app[781117ef1d5478] mad [info] at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12) 2024-04-04T22:45:00Z app[781117ef1d5478] mad [info] at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38) 2024-04-04T22:45:00Z app[781117ef1d5478] mad [info] at importModuleDynamicallyCallback (node:internal/modules/esm/utils:207:14) 2024-04-04T22:45:01Z app[781117ef1d5478] mad [info] INFO Main child exited normally with code: 1 2024-04-04T22:45:01Z app[781117ef1d5478] mad [info][ 11.274317] reboot: Restarting system
vite.config.ts
`import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { flatRoutes } from "remix-flat-routes";
import {
expressDevServer,
expressPreset,
} from "remix-express-vite-plugin/vite";
installGlobals();
export default defineConfig({
build: {
cssMinify: process.env.NODE_ENV === "production",
},
server: {
port: 3000,
},
plugins: [
expressDevServer(),
remix({
presets: [expressPreset()],
ignoredRouteFiles: ["**/*"],
routes: async (defineRoutes) => {
return flatRoutes("routes", defineRoutes, {
ignoredRouteFiles: [
".*",
"**/*.css",
"**/*.test.{js,jsx,ts,tsx}",
"**/__*.*",
// This is for server-side utilities you want to colocate
// next to your routes without making an additional
// directory. If you need a route that includes "server" or
// "client" in the filename, use the escape brackets like:
// my-route.[server].tsx
"**/*.server.*",
"**/*.client.*",
],
});
},
}),
tsconfigPaths(),
],
});
`
Once again thank you for the quick answer in Discord. :)
Perfect thanks
This is fixed, but I'm working on v0.2.0, which simplifies things even further. It also splits the Vite plugin from the Express app, since Vite is only used for development, but Express needs to be installed as a regular dependency.