Font-awesome integration in Vue.js causing extremely slow hot reloading

Recently, I decided to embark on a fun project using Vue.js because working with this framework seemed enjoyable. To enhance my project, I chose to incorporate the https://github.com/FortAwesome/vue-fontawesome component. However, upon using it in one of my Vue components:

<template>
  <div class="success-box-wrapper">
    <div class="box">
      <div class="box-header">
        <span class="close">x</span>
      </div>
      <div class="box-body">

      </div>
      <div class="box-footer">
        <div class="checkmark-circle">
          <div class="background"></div>
          <font-awesome-icon fa :icon="faCheck"/>
          <div></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { faCheck } from '@fortawesome/free-solid-svg-icons';

export default {
  name: 'SuccessBox',
  data() {
    return {
      isOpen: false,
      faCheck,
    };
  },
};
</script>

<style>
</style>

The webpack build process for my project has become unusually slow.

DONE  Compiled successfully in 54369ms10:04:26 AM
This sluggish performance occurs not only after adding the
<font-awesome-icon fa :icon="faCheck"/>
, but with any subsequent changes as well. I attempted to move webpack outside of Vue, but encountered issues. Could it be that using font-awesome as a component is causing this slowdown? Perhaps resorting to the "old" method by inserting a CDN reference might be more efficient?

node_1  |  WAIT  Compiling...10:03:32 AM
node_1  |
(node_1 logs continue)
      

WORKAROUND-LIKE SOLUTION IMPLEMENTED:

Prior to employing a workaround solution, I was running yarn serve within a Docker container, resulting in prolonged compilation times during hot reloads. Contrastingly, launching the project directly on Windows yielded compile times of just 500ms. This issue persists unresolved, as the cause behind the sluggishness when run through Docker remains elusive.

Answer №1

After experiencing a challenging few days dealing with this issue, I believe I've identified a solution.

In my case, the problem did not arise after adding any specific package via yarn/npm. Additionally, I am utilizing Windows as the host OS with Linux containers.

Upon starting a new project with vue-cli, everything functioned smoothly. However, upon dockerizing it, the HMR performance became unbearably slow.

There appear to be two primary factors at play here: the port in use and the build time within node_modules/.

Addressing either of these aspects individually did not yield significant improvement. Nevertheless, resolving both drastically improved the HMR performance, almost bringing it back to its native level.

To fix these issues, I made the following adjustments:

docker-compose.yml

version: '3.7'

services:

  front-end:
    container_name: my-front-end
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - '.:/app'
      - '/app/node_modules' # <---- this enables a much faster start/reload
    ports:
      # default port does work but slow without mounting node_modules (above)
      # - '8080:8080'
      # for some reason HMR breaks completely when not using the same port as the container.
      # - '8007:8080'
      # - '8006:8007'
      # port 8007 set up in vue.config
      - '8007:8007'
    #   this is now also done in the vue.config
    # environment: 
      # - CHOKIDAR_USEPOLLING=true

vue.config.js

module.exports = {
    devServer: {
        public: "localhost:8007",
        port: 8007,
        disableHostCheck: true,
        watchOptions: {
            ignored: /node_modules/,
            aggregateTimeout: 300,
            poll: 300,
        },
    },
};

I trust this information proves helpful to someone facing a similar challenge.

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

Discovering time overlaps with Javascript and moment.js

In my calendar project, I am storing events for a day in an array. The start and end times are stored as String values in the following format: Example of events in a day const events = [{ "_id": "5bdf91a78197f0ced6c03496", "user": "5bd62237d6 ...

Show a popover within a parent div that has limited visible space due to its hidden overflow

Struggling with AngularJS, I can't seem to find a simple solution for this problem. In my code, there's a div element with the overflow: hidden property set due to an internal scrollbar. Inside this div, there's a dropdown menu that is trigg ...

Update the array by incorporating a new object that corresponds to a provided list with a unique key-value pair

When selecting objects from a list using a checkbox, I want to make the selection recognizable by adding a new key-value pair to the selected objects with the label of the selected value. This is what I have tried: var checkCheckboxOnOff = [{"fieldName": ...

Communication through Collaboration Diagrams

For my software engineering project, I am working on creating communication diagrams. However, I am struggling with understanding how to draw if-then statements. Can anyone provide assistance with this? I have tried looking on YouTube for tutorials, but u ...

Having difficulties in storing the checkbox selections

Whenever I switch components and return back, the checkboxes do not persist. I want to ensure that the checked checkboxes stay checked. For more information and code samples, you can visit this CodeSandbox link: CodeSandbox Link. courses.js import React ...

Incorporate a file into all API endpoints with Next.js API functionality

Is there a way to incorporate a "bootstrap" file (a file with side-effects) as the first file included in all Next.js APIs? The main issue is that I have a Winston logger in a file that needs to be added to every API endpoint, but this process hinders dev ...

Increasing Asynchronous Capabilities with Dynamically Updating jQuery Deferred within then() Method

I am currently exploring the functionalities of jQuery Deferred and I have encountered a challenge regarding chaining multiple deferreds. Let me outline my simplified issue: var def1 = $.ajax(...); // executing ajax call 1 var def2 = null, def3 = null; $ ...

Embracing Micro Front End Development

Currently, I have a legacy AngularJS (Angular 1) app that cannot undergo any major changes at the moment. A new standalone app has been created using a newer stack. The goal is to integrate this new app into the old legacy app without making significant m ...

struggling to implement promises in mongoose operations

Can anyone explain why this promise setup is not functioning as expected? The goal was to remove the documents, add new ones, find them, and then output the data, but it's not displaying anything. var Comp = require("./models/company.js"); var ar ...

In Angular, what is the best way to change the format of the timestamp '2019-02-22T12:11:00Z' to 'DD/MM/YYYY HH:MM:SS'?

I am currently working on integrating the Clockify API. I have been able to retrieve all time entries from the API, which include the start and end times of tasks in the format 2019-02-22T12:11:00Z. My goal is to convert the above date format into DD/MM/Y ...

The axios response cannot be awaited in Jest unit tests

While unit testing my Vue-Electron project with Jest, I encountered an issue where a chain of events triggered by a fake button click was not functioning as expected. In the midst of this chain, an axios request was made to a server to retrieve data, but t ...

Generate Array of Consecutive Dates using JavaScript

My array contains the following values (for example): [ 1367848800000: true, 1367935200000: true, 1368021600000: true, 1368108000000: true, 1368194400000: true, 1368367200000: true, 1368540000000: true, 1 ...

How can I use JQuery to save values from a for loop?

After working on a grid, I encountered an issue where only the last value was being returned when trying to fetch all values into an object. Unfortunately, I am stuck and unsure of how to resolve this problem. function item_details(){ var gridDataAr ...

Adjust the border colors of TinyMCE when it is in focus and when it is blurred

I'm currently working on a project using jQuery in conjunction with TinyMCE. I am focusing on changing the border colors when the TinyMCE editor is in focus, and then reverting them back to their original color on blur. Here's the snippet I&apos ...

Is it possible for AWS Lambda to store global variables?

I've devised a basic increment counter shown below. global.counter = 0; exports.handler = (event, context, callback) => { // TODO implement callback(null, ++global.counter); }; Every time I test this function, the value increments as anti ...

Utilize Google Maps' Java Script feature to include a second address on the map

I have successfully implemented the code to display an address on a map instead of latitude, but now I am stuck. I tried adding a second var addresss, but my coding knowledge is limited. Can someone please assist me? <html> <head> <meta n ...

Change the parent properties within the child component, and then utilize these modified properties again within the child component

I am currently working on a React application where I am facing a challenge with modifying the props passed from the parent component in my child component. My goal is to update the parent props when a counter is clicked in the child component, and then be ...

Retrieving user information from Firebase with Promise instead of Observable

In my React project, I successfully implemented the Observer pattern to retrieve user data from Firebase. This approach made perfect sense and here is a snippet of the code where I utilized the observer pattern: unsubscribeFromAuth = null; componentDidMou ...

CSS not being properly rendered on newly inserted row within table via jQuery

I'm currently working on a table that allows users to select rows, and I've implemented some CSS to highlight the selected row. The issue arises when new rows are added to the table as they do not get highlighted when selected. HTML Portion: &l ...