electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.51k stars 520 forks source link

Electron Forge ignores rollupOptions in vite.renderer.config.ts #3675

Closed Dozorengel closed 3 months ago

Dozorengel commented 3 months ago

Pre-flight checklist

Electron Forge version

7.4.0

Electron version

31.4.0

Operating system

macOS 14.6

Last known working Electron Forge version

No response

Expected behavior

I try to load multiple html files within a single vite.renderer.config.ts. I set two entry points in rollupOptions like this:

import type { ConfigEnv, UserConfig } from "vite"
import { defineConfig } from "vite"
import { pluginExposeRenderer } from "./vite.base.config"
import { resolve } from "path"

// https://vitejs.dev/config
export default defineConfig((env) => {
  const forgeEnv = env as ConfigEnv<"renderer">
  const { root, mode, forgeConfigSelf } = forgeEnv
  const name = forgeConfigSelf.name ?? ""

  return {
    root,
    mode,
    base: "./",
    build: {
      outDir: `.vite/renderer/${name}`,
    },
    plugins: [pluginExposeRenderer(name)],
    resolve: {
      preserveSymlinks: true,
    },
    clearScreen: false,
    rollupOptions: {
      input: {
        main_window: resolve(__dirname, "index.html"),
        modal_window: resolve(__dirname, "modal.html"),
      },
    },
  } as UserConfig
})

Actual behavior

It seems to me that forge completely ignores rollupOptions property, as no matter how hard I try, modal.html didn't appear in .vite/renderer dir.

Steps to reproduce

  1. init quick-start app
  2. create modal.html in root
  3. load modal.html via modalWindow.loadFile, same way as mainWindow.loadFile
  4. add rollupOptions.input section in vite.renderer.config.ts, define two paths to html files
  5. run npm run package, make sure that somehow there are no any other html files except index.html

Additional information

Dev mode via npm start is working fine with multiple html. The issue occurs during the build stage

Dozorengel commented 3 months ago

I made a mistake, I should have added rollupOptions into build section, after that everything is working fine