Only index.html is generated on build

Since glitch redirects “non-existing” routes to index.html on Generated Static sites, I tried to add a .html file of the page I use to trick glitch and allow the users to access it, but when I check the builds folder the other .html file isn’t there, and instead only index.html is and assets present.

I would love if on glitch.json I could add a path to be considered existent
But I can’t do it as of now so ¯\_(ツ)_/¯

The project can be seen here: Glitch :・゚✧ Project

1 Like

Hi @Awakened-Redstone! I tried to replicate your issue on your project but I couldn’t seem to get it to… break! If you have already solved the issue, mind marking this as Solved so other users don’t try to contribute? :slight_smile:

1 Like

That is weird, since if I try to go to the /mods page when the app is providing the production build, I get redirected to /, this behavior is expected when there isn’t a file corresponding to /mods, but on the source there is one, but if I do ls build I’ll get

$ ls build
assets  index.html

When the app is running the development build it works perfectly fine, since glitch won’t redirect paths that supposedly would result on a 404 to index.html when the app is running, and only when distributing the production build

1 Like

try /mods.html :slight_smile:

Same behavior, but /index.html works, but since I’m using react router it gives me a 404 error

I got it working, I had to add this to vite.config.js

rollupOptions: {
  input: {
    main: resolve(__dirname, 'index.html'),
    nested: resolve(__dirname, 'mods/index.html')
  }
}

And my final vite.config.js is this

import { defineConfig } from "vite";
import { resolve } from "path";
import reactRefresh from "@vitejs/plugin-react-refresh";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [reactRefresh()],
  build: {
    outDir: "build",
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html'),
        mods: resolve(__dirname, 'mods/index.html')
      }
    }
  },
  server: {
    strictPort: true,
    hmr: {
      port: 443 // Run the websocket server on the SSL port
    }
  }
});

For the /mods path to work properly it needs to have the <script type="module" src="/src/index.jsx"></script> on the mods/index.html file still, I may create an example of a multipage react app using react router later

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.