electron-userland / electron-webpack-quick-start

A bare minimum project structure to get started developing with electron-webpack.
https://webpack.electron.build/
730 stars 258 forks source link

HMR not working with default clone and yarn dev #53

Closed polarathene closed 5 years ago

polarathene commented 5 years ago

I installed the project as per the README instructions, ran yarn, then yarn dev, project window pops up, brings in Vue or whatever the renderer index.js is doing(the code appears minified? is that suitable for getting a feel of the project?)... then I edit some text in the js file and save it. Nothing happens. DevTools window console states HMR has been enabled:

[HMR] Waiting for update signal from WDS...
[WDS] Hot Module Replacement enabled.

Console output:

yarn dev
yarn run v1.13.0
$ electron-webpack dev
┏ Main -----------------------

  Hash: 1cd20ade4f0bb5d28692
  Version: webpack 4.28.4
  Time: 184ms
  Built at: 01/27/2019 3:39:44 PM
    Asset      Size  Chunks             Chunk Names
  main.js  41.3 KiB    main  [emitted]  main
  Entrypoint main = main.js
  [0] multi ./node_modules/electron-webpack/out/electron-main-hmr/main-hmr ./src/main/index.js 40 bytes {main} [built]
  [./node_modules/electron-webpack/out/electron-main-hmr/main-hmr.js] 582 bytes {main} [built]
  [./src/main/index.js] 1.42 KiB {main} [built]
  [electron] external "electron" 42 bytes {main} [built]
  [electron-webpack/out/electron-main-hmr/HmrClient] external "electron-webpack/out/electron-main-hmr/HmrClient" 42 bytes {main} [built]
  [path] external "path" 42 bytes {main} [built]
  [source-map-support/source-map-support.js] external "source-map-support/source-map-support.js" 42 bytes {main} [built]
  [url] external "url" 42 bytes {main} [built]

┗ ----------------------------
┏ Renderer -------------------

  ℹ 「wds」: Project is running at http://localhost:9080/

┗ ----------------------------
┏ Renderer -------------------

  ℹ 「wds」: webpack output is served from /
  ℹ 「wds」: Content not from webpack is served from /storage/projects/electron/hmr-test/static, /storage/projects/electron/hmr-test/dist/renderer-dll

┗ ----------------------------
┏ Renderer -------------------

  ℹ 「wdm」: Hash: 2d017872700bf5eeb4e6
  Version: webpack 4.28.4
  Time: 454ms
  Built at: 01/27/2019 3:39:45 PM
        Asset       Size    Chunks             Chunk Names
   index.html  379 bytes            [emitted]  
  renderer.js    841 KiB  renderer  [emitted]  renderer
  Entrypoint renderer = renderer.js
  [0] multi (webpack)-dev-server/client?http://localhost:9080 (webpack)/hot/dev-server.js css-hot-loader/hotModuleReplacement ./src/renderer/index.js 64 bytes {renderer} [built]
  [./node_modules/css-hot-loader/hotModuleReplacement.js] 2.96 KiB {renderer} [built]
  [./node_modules/electron-webpack/package.json] 1.5 KiB {renderer} [built]
  [./node_modules/lodash/debounce.js] 5.93 KiB {renderer} [built]
  [./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {renderer} [built]
  [./node_modules/normalize-url/index.js] 3.85 KiB {renderer} [built]
  [./node_modules/strip-ansi/index.js] 161 bytes {renderer} [built]
  [./node_modules/webpack-dev-server/client/index.js?http://localhost:9080] (webpack)-dev-server/client?http://localhost:9080 7.78 KiB {renderer} [built]
  [./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.58 KiB {renderer} [built]
  [./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {renderer} [built]
  [./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {renderer} [built]
  [./node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.61 KiB {renderer} [built]
  [./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 75 bytes {renderer} [built]
  [./node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js 1.27 KiB {renderer} [built]
  [./src/renderer/index.js] 1.72 KiB {renderer} [built]
      + 29 hidden modules
  Child html-webpack-plugin for "index.html":
       1 asset
      Entrypoint undefined = index.html
      [./node_modules/html-loader/dist/cjs.js?minimize=false&url=false!./dist/.renderer-index-template.html] 346 bytes {0} [built]

┗ ----------------------------
┏ Renderer -------------------

  ℹ 「wdm」: Compiled successfully.

┗ ----------------------------
┏ Electron -------------------

  Debugger listening on ws://127.0.0.1:5858/80e6ead2-1fbf-40ad-8781-f5998784c301
  For help, see: https://nodejs.org/en/docs/inspector

┗ ----------------------------

node -v: v11.3.0 electron -v: v3.1.1 (system install, I don't think this project is using it though?) OS is Manjaro KDE (Linux)

polarathene commented 5 years ago

Not sure what has happened, but ran project again since and it's now working correctly(no changes to project code or any other command run besides yarn dev)

alejandro-ultimatejetvacations commented 5 years ago

Same error here, do you have any clue on how to solve it?

polarathene commented 5 years ago

@Alejpf I am not sure what caused it. As I said, when I tried to work on it again at a later point, it was working properly.

It might have been due to something like file watchers. I often would hit the default limit on my system and get warnings in some projects/apps that they could not function properly due to exceeding the limit. Perhaps I had freed those up by closing some stuff and that resolved it? Restarting your system should work too.