Troubleshooting VueJS, Electron, and Webpack integration with Hot Reload feature

I have been immersed in a new project that involves utilizing Electron, VueJS, and Webpack for HMR functionality. Unfortunately, I am encountering difficulties with the Hot Module Replacement feature not working as expected.

Here is my current configuration:

Webpack Configuration (webpack.config.js)

var path = require('path');
var webpack = require('webpack');

module.exports = {
  entry: './app/index.js',
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'build.js',
  },
  resolve: {
    alias: {
      'vue': 'vue/dist/vue.common.js',
    },
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.css/,
        loader: 'style-loader!css-loader',
      },
    ],
  },
  plugins: [
    new webpack.ExternalsPlugin('commonjs', [
      'electron',
    ]),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.LoaderOptionsPlugin({
      babel: {
        'presets': ['env'],
        'plugins': ['transform-runtime'],
      },
    }),
  ],
};

HTML File for Vue Mounting Point (index.html)

<!DOCTYPE html>
<html>

  <head>
    <title>Hermes - Empyrion Environment Editor!</title>
    <style>
      body {
        background-color: #222222;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>

  <body>
    <div id="root"></div>
    <script src="http://localhost:8080/webpack-dev-server.js"></script>
  </body>

</html>

JavaScript File for Electron Initialization (index.js)

const electron = require('electron');
const { app, BrowserWindow } = electron;

let mainWindow;

app.on('ready', () => {
  let mainWindow = null;
  const loadingWindow = new BrowserWindow({
    width: 325,
    height: 425,
    frame: false,
    show: false,
  });
  
  ...

The issue arises when trying to implement Hot Module Replacement. When using

http://localhost:8080/dist/build.js
in the index.html, the app runs in Electron without HMR. However, if I switch to
http://localhost:8080/webpack-dev-server.js
as the script source, the app fails to load content upon launch.

Even though the console outputs indicate that HMR is enabled, the app does not fully initialize. Interestingly, accessing

http://localhost:8080/loading.html
works perfectly, leading me to believe the issue lies within the <script> reference in index.html.

I suspect the problem may be related to the file:// path used in the Electron initialization section of the code. Any insights or solutions would be highly appreciated. Thank you in advance!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Conceal the navbar during the process of the ajax loader loading

My current issue involves utilizing an AJAX loader to conceal my page until all elements have loaded. Unfortunately, the navbar is not hidden along with the other content as shown in the image below. I need assistance in ensuring that everything, including ...

Is it possible to output the value of history.go(-1) using a print function?

Currently, I'm working on enhancing a Vue application. My goal is to retrieve the value of the previously visited page using history.go(-1) and then use that value to assign certain values to a variable. This is what I have in mind: <script> ...

Modify the numerical presentation within the provided input text

Looking to format numbers in the thousands with a comma, for example changing 2000 to 2,000 and 20000 to 20,000. While I found a solution using cleave.js library, it only works for one input field. Is there another alternative that can handle multiple in ...

Adjust the CSS within a <style> element using jQuery or javascript

What I aim to accomplish: I intend to dynamically add and modify rules within a <style> tag using JavaScript/jQuery. Reason behind this goal: I am in the process of creating a color scheme editor where changes made by the user should be reflected ...

Expanding a SAPUI5 class by incorporating a pre-determined header

In my attempt to expand a class using SAPUI5 methodology, I created a basic version to test its functionality. However, the predetermined title is not displaying in this particular example: var app; sap.m.Page.extend("MyPage", { title: "hi", rendere ...

Get the div to occupy the rest of the available height

I am facing a challenge with two divs on my webpage. The bottom one contains content that expands the highest. The page is set to 100% height and width using the CSS property position: absolute. <style> body, html { height:100%, width:100% } ...

"Obtaining a URL that begins with using jQuery: A Step-by-

How can I extract the full URL that starts with http://sin1.g.adnxs.com Here is the code snippet: <div id="testingurl"> <div class="ads98E6LYS20621080"> <!-- This script is dynamically generated --> <iframe src="http://testing ...

Insert an element at the start of a sorted array object

I am currently working on a small application that has the following structure: Posts -> Post -> Comments -> Comment. The Posts component sends a request for an array of posts sorted by date in descending order. Each post also fetches its comment ...

Observables waiting inside one another

I've encountered an issue where I need to return an observable and at times, within that observable, I require a value from another observable. To simplify my problem, let's consider the following code snippet: public dummyStream(): Observabl ...

Function for querying database is not executing in an asynchronous manner

After setting up a function in my node server to handle querying the database and returning results, I found that using async await could help streamline the process throughout my routes. This way, I wouldn't end up with nested queries within one anot ...

When refreshing a JavaScript array of objects, it creates duplicate entries within the array

Currently, I am developing a chat application within a Vue project and experimenting with different features. A fully-featured chat app must have the ability to live-update "seen" states. This means that when one user views the last sent message, the othe ...

Determine the exposed area of an element with overflowing content

I am looking for a way to determine which text within an element (such as a div or textbox) is currently visible when there is overflow. As the user scrolls, I need to have an updated list of the visible text. I am open to using any elements, but only a ...

Troubleshooting issues with rowspan in a Datatable

I am currently utilizing jQuery DataTables to display my grid data and implementing the rowspan concept with the rowsGroup option. Initially, it works well by spanning some rows and looking visually pleasing, but eventually, it starts failing. Here are so ...

Leveraging the power of context to fetch data from a store in a React component within the Next

I'm having trouble with the title in my React project, and I'm new to React and Nextjs. When trying to fetch data from my dummy chat messages, I encountered this error: × TypeError: undefined is not iterable (cannot read property Symbol(Sy ...

Empty text box

I've been attempting to clear ng-model inputs, but haven't had any success and I can't seem to figure out why. Here is what I have: <button ng-click="$ctrl.clear()"></button> And in the clear action, I have: $scope.$event = n ...

Using formidable to parse form data in Node.js

Hello everyone, I'm a beginner with node.js and I'm currently working on setting up a file/image upload script. After successfully installing node on my VPS, I came across this helpful guide that assisted me in setting up the app with formidable ...

Executing a Component function within an "inline-template" in VueJS

VueJS version 1.9.0 app.js require('./bootstrap'); window.Vue = require('vue'); Vue.component('mapbox', require('./components/mapbox.js')); const app = new Vue({ el: '#app' }); components/mapbox.js ...

Finding the perfect spot to CAPTURE an ERROR triggered during an EVAL operation

This snippet of code allows you to run JavaScript code while using a try/catch block to catch any errors that may occur. try { var result = eval(script); } catch (e) { // handle the error appropriately } However, if the variab ...

Does every controller page need to verify the Login Function?

In my PHP pages, I have implemented the MVC Pattern by creating a controller page for each view page to interact with the Model page. However, I have only checked user login at the top of every view page and not in the controller page. This leaves a potent ...

Combining ng-filter and ng-repeat to iterate over key-value pairs in objects

Currently, I am utilizing the built-in Angular 1 filters in an attempt to filter out a property of an object. While Angular Filters typically only accept Arrays and not Objects, the structure of the web application prevents me from refactoring to pass an a ...