Electron preload scrip for webview not working?


I maybe stupid but i’ve been looking for an anwser for the past 2 hours.

I have this webview that i load like this :

<webview id="link-view" src="http://url.espace.com/" preload="./preload.js" autosize="on" partition="persist:link"></webview>

In the preload.js file which is in the same directory i have this :


This does not work, can somebody explain this to me ? :frowning:


come on , nobody knows that ?


Are you sure you see the output to console of webview, not of BrowserWindow?
Try replace console.log to alert


I used alert instead, no alert poping … how can i look at the console of the webview , i’m looking both at the console of the renderer process and the main process ( terminal and devtool)

what am i doing wrong ?


FOUND IT , i used electron boilerplate to load, and the preload.js wasnt involved in the gulpfile ! :smiley:


Which bundler is the boilerplate using? I’m having a similar issue.


This solved my problem in electron 3.0.0-beta.4 using react.js
<webview src={‘http://example.com’} preload={file://${__dirname}/preload.js}/>