cawa-93 / vite-electron-builder

Secure boilerplate for Electron app based on Vite. TypeScript + Vue/React/Angular/Svelte/Vanilla
MIT License
2.38k stars 259 forks source link

Renderer process can not import electron #121

Closed xiaohulu closed 3 years ago

xiaohulu commented 3 years ago

I add below code to renderer/app.vue

import {ipcRenderer} from 'electron';

then npm run watch report errors index.js:4 Uncaught ReferenceError: __dirname is not defined npm run compile success, but load failed and report errors index.html:1 Uncaught TypeError: Failed to resolve module specifier "electron". Relative references must start with either "/", "./", or "../".

xiaohulu commented 3 years ago

Fixed by Using electron API in renderer.

ErriourMe commented 2 years ago

Hey. I have the same question now. How to access to electron from vue template now right way? Fix description already removed ;(

cawa-93 commented 2 years ago

@ErriourRU. Docs. In preload you should create global function or something. And just use it in renderer from global scope