skpm / with-webview

Template for skpm using a webview
40 stars 21 forks source link

Hot rebuild not working #3

Closed gabrielenosso closed 7 years ago

gabrielenosso commented 7 years ago

If I change the code, it rebuilds but Sketch doesn't read the new version. I have to close and reopen it to see the modifications.

Is there any step I missed to let it work?

mathieudutour commented 7 years ago

it depends if you use the shouldKeepAround option. If you do, then you need to close sketch and reopen it. That being said, if you just change the html or the js of the webview, you can just reload it (right-click -> reload)

gabrielenosso commented 7 years ago

I tried the plugin with the 'shouldKeepAround' option set to "false", but Sketch crashes... Sometimes it crashes at the startup, sometimes as soon as I click on the "Get a random number" button.

gabrielenosso commented 7 years ago

Also, using 'npm run watch' to start the project, if I change the .html file of the webview and reload it (right-click -> reload), it doesn't show in sketch the new version.

mathieudutour commented 7 years ago

Yeah you need to use shouldKeepAround if you want to talk to the plugin

gabrielenosso commented 7 years ago

So is there a way to have a quick reload of the plugin - or of the webview- using 'shouldKeepAround'? Or closing and reopening Sketch is the only way?

mathieudutour commented 7 years ago

You can setup a webpack dev server and point the webview to it. It’s a bit more work

On 26 Oct 2017, at 15:19, Gabriele Nosso notifications@github.com wrote:

So is there a way to have a quick reload of the plugin - or of the webview- using 'shouldKeepAround'? Or closing and reopening Sketch is the only way?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

gabrielenosso commented 7 years ago

Do you think it would be possible to close Sketch and reopen it? Using something like: osascript -e 'quit app "Sketch"' from the Terminal, which soft closes the app.

mathieudutour commented 7 years ago

Oh yeah that’s possible but I think it’s easier to use webpack-dev-server :)

On 26 Oct 2017, at 15:54, Gabriele Nosso notifications@github.com wrote:

Do you think it would be possible to close Sketch and reopen it? Using something like: osascript -e 'quit app "Sketch"' from the Terminal, which soft closes the app.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

gabrielenosso commented 7 years ago

but the webpack-dev-server would work only for the webview, not for the plugin. And anyway you would need a way to reload it in Sketch.. no?

mathieudutour commented 7 years ago

Oh yes that’s very true, I’ll try to think about it

On 26 Oct 2017, at 16:05, Gabriele Nosso notifications@github.com wrote:

but the webpack-dev-server would work only for the webview, not for the plugin. And anyway you would need a way to reload it in Sketch.. no?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.