New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full node-js support for electron main process. #73
Comments
check out: #71 (comment) for more details import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()],
},
preload: {
plugins: [externalizeDepsPlugin()]
},
// ...
}) I don't know if it will help you. |
Thanks! for the suggestion @alex8088 Just to give you a bit more context. We are not able to access the assets when I guess this will be a common scenario for apps with many deps in main scripts. It would be great, if there is an option to export the certain assert types in main scripts with |
For wasm, you can try the rollup plugin @rollup/plugin-wasm. Or, via polyfill: export default defineConfig({
main: {
resolve: {
alias: {
'@aws-sdk/xxx': 'polyfills/xxx',
},
},
}
}) |
|
Above is an example of main config for electron-vite Lets say we listed all isomorphic modules and avoided ssr. Then here is my bundle output looks like with ssr:false
Then I face two problems.
After resolution, I get a relative path in both the cases I hope this clarifies. May be there is an easier way or the problem is complex, let me know if you have any questions |
Simple question would be around. If electron-vite builds the main in library mode then i guess it should have inlined all assets. https://vitejs.dev/config/build-options.html#build-assetsinlinelimit One solution works for me: increase Interestingly : electron-vite version 1.0.12 bundles all assets inline without explicitly specifying assetsinlinelimit. I guess it is because of library mode but after that something has changed. |
@janakg Nice, please provide a test repo. Maybe I try to find a best solution. |
PFA test case repo if you enable the Irrespective of wasm module loading. How to load any asset file like a font in main proecss? you can reproduce that , just by commenting off the wasm module lines and just keeping
Let me know if you have any questions We need check this thread for hints: vitejs/vite#3295 |
Even resolution of public assets are not working. PFA a branch with publicDir for assets handling Also, I am trying to avoid multiple copies of public directory assets used across renderer and main. |
Hello |
Both
My solution:
I tried this way and it loads correctly, but doesn't get the exports of wasm. I don't know if it's a wasm file problem or a plugin problem.
check out: Public Directory
My solution:
const base64 = await fs.readFile('*.ttf', { encoding: 'base64' })
... |
For wasm, electron-vite plans to support it in future. Maybe next or ... |
@alex8088 Thanks! |
new ver v1.0.17 is out! It optimizes the static asset handling in the Electron main process. |
Electron vite for main process
We are new to vite eco-system, moving a large electron application from webpack to vite using electron-vite plugin. One of our dep. package is @AWS-SDK , so we landed in the below issue. Vite doesn't have full support for "mainFields" or "environment". We needed to use
ssr:true
in the main.vitejs/vite#4405
Once we do that, asset handling of vite is getting messed up. It is trying to fetch() an asset from chunks/hb.cb53d2e0.wasm inside the bundled js code and fails, as it has not exported to that path and also fetch() in node process is a node-fetch polyfill that doesn't support 'relative urls'.
Suggested solution
Can we think of a solution out side vite for bundling main scripts as vite is primarily for frontend tooling? also please suggest if there is any simple way to achieve the same.
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: