farm-fe / farm

Extremely fast Vite-compatible web build tool written in Rust
https://farmfe.org
MIT License
5.05k stars 165 forks source link

[Bug Report]: can't use 'vite-plugin-electron-renderer' in farm #1977

Open L-x-C opened 3 days ago

L-x-C commented 3 days ago

Steps to reproduce

in farm.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import renderer from 'vite-plugin-electron-renderer'
export default defineConfig({
  plugins: [
    vue(), 
    renderer()
  ],
})

shows

[ Farm ] Error: Failed to start the server
Caused by: Error: Vite plugin 'vite-plugin-electron-renderer' is not compatible with Farm for now. Because it uses viteConfig.build['commonjsOptions'] which is not supported by Farm. Current supported keys are: outDir,sourcemap,minify,cssMinify,ssr,watch,rollupOptions,assetsDir

i have a web project used in electron's browserWindow, in vite, i use vite-plugin-electron-renderer. is there a way to use in farm? In my web project

import pidusage from 'pidusage'
console.log(pidusage)

or is there a way to make this work?

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 7840HS w/ Radeon 780M Graphics
    Memory: 2.47 GB / 11.72 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.51)
    Internet Explorer: 11.0.26100.1882
ErKeLost commented 2 days ago

I checked to see if the api is compatible. Electron farm has its own plugin you can try example

L-x-C commented 1 day ago

I checked to see if the api is compatible. Electron farm has its own plugin you can try example

you mean @farmfe/js-plugin-electron? it's not suitable for this situation, this is a online web project that opened in electron's BrowserWindow In webpack, i will use

target: 'electron-render'

In vite, i will use

'vite-plugin-electron-renderer'
ErKeLost commented 1 day ago

@L-x-C Okay, forgive me if I don't know enough about electron, and we'll try solve this problem.