electron / electron/forge

[plugin-vite] allow custom vite outDir

Open
#3,865 2 comments 4 reactions 0 assignees View on GitHub
plugin/vite
Dominant language
TypeScript
Stars
7.1k
Forks
641
Avg merge
3d 1h
Merged PRs (30d)
30

Description

### Pre-flight checklist

- [x] I have read the [contribution documentation](https://github.com/electron/forge/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project uses.
- [x] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

### Problem description

I try to use vite plugin but I have everything configured to output to `./dist`. I'm getting following error:

```text
An unhandled rejection has occurred inside Forge:
Error: Electron Forge is configured to use the Vite plugin. The plugin expects the
"main" entry point in "package.json" to be ".vite/*" (where the plugin outputs
the generated files). Instead, it is "dist/electron/src/main.js"
```

I've check code and search for this issue. Why we cannot specify custom output dir? Why it is hardcoded

my vite.main.config.ts looks like this:

```typescript
import { defineConfig } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';

// https://vitejs.dev/config
export default defineConfig({
build: {
outDir: './dist/electron/src/',
},
plugins: [
viteStaticCopy({
targets:[
{
src: './projects/electron/package.json',
dest: '../'
}
]
}),
],
});

```

### Proposed solution

Allow for custom baseDir

### Alternatives considered

Remove hardcoded code

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.