Just flat doesn't seem to be working with electron.
Closed this issue · 3 comments
Unfortunatly, it doesn't seem like this is working at all with the electron setup I have going.
I'm just loading up a browser window right now and loading the webpack-dev-server's URL. everything loads up fine initially, but no changes are ever reflected. The page doesn't even refresh, but I can see that webpack is rebuilding with every change.
Here's the webpack config I'm using for some context.
And I am passing the --hot
flag to the dev server. Still nothing :(
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = renderConfig = {
entry: "./src/app/index.js",
output: {
path: path.join(__dirname, "/out/app/"),
publicPath: 'http://localhost:8080/out/app/',
filename: "bundle.js"
},
mode: "development",
target: "electron-renderer",
devServer: {
publicPath: '/',
hot: true,
overlay: true
},
module: {
rules: [
{
test: /\.css/,
exclude: /node_modules/,
use: ["style-loader", "postcss-loader"]
},
{
test: /\.svelte/,
include: path.resolve(__dirname, "src/app"),
exclude: /node_modules/,
use: {
loader: "svelte-loader-hot",
options: {
hotReload: true
}
}
},
{
test: /\.js/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
},
plugins: [new HtmlWebpackPlugin()]
};
``
Thanks for feedback :)
I've been using this in an Sapper app (with Webpack) under Electron essentially since day 1, so it should work.
You need to load the dev server URL in your Electron window, for HMR to work. (Also, you don't need the --hot
flag if you already have devServer.hot: true
in your config.
I've made an example template. For me, it works both in dev mode with HMR or as static file (for production). Check it out: https://github.com/rixo/svelte-electron-template-webpack. Let me know if that works for you.
I'm closing this, since there is no problem specific to Electron that I am aware of.
@benbot Feel free to reopen with additional details, if it's still not working for you.
Sorry for not updating for a while 😅
You're repo works well for me, but mine doesn't. I can't see any obvious reason as to why though.
Probably an issue between my chair and keyboard somewhere.