berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug?]: Building executable fails in monorepo due to env file in shared package

Open caralin3 opened this issue 7 months ago • 0 comments

Self-service

  • [ ] I'd be willing to implement a fix

Describe the bug

I have a monorepo created using yarn workspaces where I have this structure.

apps/
    electron/
packages/
    database/

The electron app has the database package as a dependency. And the database package has its own .env file.

// apps/electron/package.json
{
  ...
  "dependencies": {
    ...
    "@notes-app/database": "1.0.0",
  }
}

After I build all of the shared packages, I go to build the electron app for production, but it fails with this:

 ⨯ /Users/notes-app/packages/database/.env must be under /Users/notes-app/apps/electron/  failedTask=build stackTrace=Error: /Users/notes-app/packages/database/.env must be under /Users/notes-app/apps/electron/

I am building the database package via rollup with this: "build": "rollup -c --bundleConfigAsCjs --environment INCLUDE_DEPS,BUILD:production",

I am building the electron app with this: "build:mac": "electron-vite build && electron-builder --mac",

How can I get this to work? Do I need to have a shared .env file at the root of the monorepo? Or do I need to build the database package a different way somehow that includes the env variables?

To reproduce

Run yarn run electron:build:mac

Environment

System: OS macOS 14.6.1

Additional context

No response

caralin3 avatar May 21 '25 16:05 caralin3