Make Vuetify icons display properly while loading a page from the local filesystem

I have set up a vue project using vue cli 3 and integrated Vuetify v2.0.19.

One of the requirements for my project is to be able to compile it into a single HTML file so that it can be downloaded and run offline in a phonegap app (specifically on Safari v13). While I've been successful in meeting most of the project's needs, one issue persists - the icons are not displaying correctly. Whenever I use

<v-icon>info</v-icon>
, for instance, instead of the icon rendering, it simply shows the word INFO.

I've followed the instructions provided in the Vuetify Quick-Start guide, Icons documentation, Browser Support resources, and numerous threads on Stack Overflow, but have yet to find a solution to this problem.

My main objective is to include the necessary fonts within the single build file. When loading the page on the phonegap app or serving it from the filesystem, I consistently receive 'not found' errors in the console like

(file:///D:/fonts/materialdesignicons-webfont.27cb2cf1.woff2)
. Although I understand that the path is incorrect, how can I ensure that the icons are part of the built file?

Is there a way to achieve this?

In order to generate the single html file with embedded js and css, I made use of npm packages such as html-webpack-plugin and

html-webpack-inline-source-plugin
. Additionally, the following configurations were added to my vue.config.js file:

const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
module.exports = {
    css: {
        extract: false,
    },
    configureWebpack: {
      optimization: {
        splitChunks: false
      },
      plugins: [
        new HtmlWebpackPlugin({
          filename: 'output/output.html',
          template: 'src/output-template.html',
          inlineSource: '.(js|css)$' // embed all javascript and css inline
        }),
        new HtmlWebpackInlineSourcePlugin()
      ]
    },
    transpileDependencies:[/node_modules[/\\\\]vuetify[/\\\\]/]
  }

Furthermore, in the src/plugins/vuetify.js file:

import Vue from 'vue'
import Vuetify from 'vuetify/lib'
import '@mdi/font/css/materialdesignicons.css'

Vue.use(Vuetify)

export default new Vuetify({
  icons: {
    iconfont: 'mdi',
  }
})

Answer №1

After going through some trial and error, I finally managed to make it work just the way I wanted by following the instructions provided here.

 // plugins/vuetify.js

import Vue from 'vue'
import Vuetify from 'vuetify/lib'

Vue.use(Vuetify)

export default new Vuetify({
  icons: {
    iconfont: 'mdiSvg'
  }
})

In the components where I am using the icons (such as the mdi information icon)

<template>    
    ...
       <v-icon>{{svgPath}}</v-icon>
    ...
</template>
<script>
import {mdiInformation} from '@mdi/js'
  export default {
      ...
      data() {
          return {
              svgPath: mdiInformation
          }
      }
  }
</script>

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

Having trouble configuring the drizzle vue plugin to work with vuejs 2

After following the official documentation for setting up drizzle with vuejs 2 located here, I attempted to run my project using yarn serve. However, during this process, I encountered several errors as shown in the image https://i.stack.imgur.com/hvmnm.jp ...

Keep the first column of an HTML table fixed as you scroll horizontally

Below is an HTML table that I have created: <table id="customers" class="table table-bordered" width="100%"> <thead> <tr> <th colspan="2">Activities</th> <th>Mon 17</th> <th>Tue 18</th> </thead> ...

The script I added is malfunctioning when I utilize laravel/ui

Recently, I started using a template from node js during a course. While reading various posts, I learned that bootstrap utilizes jquery. It dawned on me that the script placed in the head section was causing issues when inserting scripts in other views. ...

Steps for storing API information in localStorage:1. Retrieve the API data

My app is running sluggish due to the excessive API calls for information retrieval. To optimize performance, I want to create a unified object containing all the data that can be shared across pages and accessed from localStorage, thus enhancing the app ...

Ways to transmit information from a modal to a function

Trying to figure out how to update data in an ng-grid after submitting a modal form with multiple text input controls. Should the ajax create function be called within the $scope.open controller section or resolve? $scope.open = function (size) { var mo ...

How can I implement a feature in Django where clicking on a form will automatically clear the initial text within it?

One common feature seen on websites is the username form box that initially displays "username" as a placeholder text. Upon clicking on the box, the word "username" disappears to allow users to input their own username. Appreciate it! ...

Using Jquery to handle input data in a form

Using jQuery, I have set up an AJAX function to fetch data from a database in real-time as the user fills out a form with 5 input fields. Currently, my code looks like this: $("#searchtype, #searchtext, #searchtag, #daterangefrom, #daterangeto").on("load ...

Angular not updating the values in real time

First and foremost, I am utilizing socket.io to emit data. Data is emitted upon connection (so the website does not appear blank) as well as when certain events occur. Upon initial connection or page refresh, everything updates and functions smoothly. Howe ...

Should I include all components in the app.js file or import them directly into the Vue component?

Now I am faced with two options for injecting my component into my application. The first method is in app.js Vue.component( "notice-master-component", require("./components/site/communication/Notice/MasterComponent.vue") ); In any Vue ...

How can we automatically add dividers after a certain number of elements in CSS?

Is there a way to create a responsive layout with CSS that automatically adds a divider after a certain number of elements? For example, I have a set of elements with the class .beers, and I want to insert a .divider element after every 5th .beers element ...

What are the benefits of removing event listeners in Reactjs?

In my opinion, the event listeners need to be reliable and consistent. React.useEffect(() => { const height = window.addEventListener("resize", () => { setWindowSize(window.innerHeight); }); return () => window.remov ...

Guide on implementing EdgesHelper with imported Collada model using three.js

Having some issues while using the EdgesHelper on a loaded Collada model in three.js: Applying edges to the entire model geometry, Misalignment and scale discrepancies between the Collada model and the generated edges. View Demo var controls, scene, ca ...

What is the process for changing a JavaScript date to the Hijri format?

Greetings! I am currently working on a web application using AngularJS/JavaScript. In my project, I have implemented a date picker and I am capturing dates from the front end. My goal is to save the selected date in the database in Hijri format. To achieve ...

The response was blocked by CORB due to cross-origin content with a MIME type of text/html

Currently working with Laravel 9 and Vue js 3, I have two projects up and running on my localhost. One project is on port 8000 while the other is on port 8001. My goal is to fetch an image from port 8001 and display it on port 8000. However, CORS is blocki ...

Adjust the position of the background when hovering with the mouse to create a right

Currently, I am implementing a background perspective change with the use of mousemove. However, an issue arises with the right margin of the image after moving it. Everything looks fine initially. Any suggestions on how to prevent this problem? https:/ ...

Is the lack of style in PHP echo using Ajax causing issues?

Encountered a Blocking Issue. Started by creating a PHP page incorporating HTML, CSS, JS, and PHP elements. The goal was to allow users to view events based on the selected date within this file. To achieve this, the selected date's value was int ...

Show selected options from 2 dropdown menus on a separate page

I need to showcase the selected options from 2 dropdown menus on a different page. Code: <form action="home/show" method="post"> <p>Vendor:</p> <select id="v" name="v"> <% @vendors.each do |vendor| %> <option ...

"Android Webview's evaluateJavascript function is not returning the expected value

I am attempting to retrieve the username from a webview, but it is returning a null object. webView.settings.javaScriptEnabled = true webView.evaluateJavascript( "(function() { return document.getElementsByClassName('lgn-loginname') })() ...

Is there a way to showcase my HTML model data in a <textarea> similar to how it appears in a web browser?

After sending a request from my ASP.NET action method, the response data comes back as HTML in my code. To show this content, I have used a <textarea> element. <textarea style="width: 85rem; height: 15rem;" ng-disabled=true ...

Organize my JavaScript code by implementing a function

I have repetitive javascript code that I would like to refactor into a function. Is there a way to streamline this process and make the code more efficient? The two functions I want to consolidate are: bright() $(VARIABLE).find('.info').fadeTo ...