Incorporating Vuetify into a Vue CLI application with the help of webpack

I am facing an issue with my Vue CLI application that uses Webpack and Vuetify. The Vuetify components are not loading properly, and I keep getting the following warnings:

Unknown custom element: < v-app > - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Unknown custom element: < v-alert > - did you register the component correctly? For recursive components, make sure to provide the "name" option.

JS File (newtab.js):

import Vue from 'vue';
import Vuetify from '../plugins/vuetify' 
import App from './App';

Vue.use(Vuetify);

new Vue({
  Vuetify,
  components: { App }, 
  render: h => h(App)
}).$mount('#app')

Vuetify Plugin File:

import Vue from 'vue';
import Vuetify from 'vuetify/lib'; 
import 'vuetify/dist/vuetify.min.css';

Vue.use(Vuetify);
export default new Vuetify({});

Vue File (App.vue):

<template>
    <v-app id="inspire">
      <v-alert type="success">
          I'm a success alert. {{ message }}
      </v-alert>
    </v-app>
</template>

<script>
//import { VApp, VAlert } from 'vuetify/lib' 

export default {
  data () {
    return {
      message: "Additional message"
    }
  }
}
</script>

<style scoped>
    p { font-size: 20px; }
</style>

I have tried using vue-loader to dynamically import the components, ensuring that all necessary packages are up to date.

├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dcaaa9b9f1bfb0b5f1acb0a9bbb5b2f1aaa9b9a8b5baa59ceef2ecf2e9">[email protected]</a> 
└── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4a3c3f2f6726252b2e2f380a7b7f6473647b">[email protected]</a>

I have also attempted to manually import the components in both the main JS file and the Vue file itself:

import Vue from 'vue';
import Vuetify, {
    VApp, VAlert
} from 'vuetify/lib';
import 'vuetify/dist/vuetify.min.css';

Vue.use(Vuetify, {
    components: {
        VApp, VAlert
    }
});
export default new Vuetify({});

Answer №1

If you want to integrate Vuetify into a Webpack project, there are a few dependencies that need to be added:

$ npm install vuetify

After installation, go to your webpack.config.js file and add the following snippet to the rules array. If you already have a sass rule set up, you may need to make some adjustments based on the changes provided below. Make sure you are using Webpack version >=4 if you want to use the vuetify-loader for treeshaking.

// webpack.config.js

module.exports = {
  rules: [
    {
      test: /\.s(c|a)ss$/,
      use: [
        'vue-style-loader',
        'css-loader',
        {
          loader: 'sass-loader',
          // Requires sass-loader@^7.0.0
          options: {
            implementation: require('sass'),
            fiber: require('fibers'),
            indentedSyntax: true // optional
          },
          // Requires sass-loader@^8.0.0
          options: {
            implementation: require('sass'),
            sassOptions: {
              fiber: require('fibers'),
              indentedSyntax: true // optional
            },
          },
        },
      ],
    },
  ],
}

Next, create a plugin file specifically for Vuetify at src/plugins/vuetify.js with the following content:

// src/plugins/vuetify.js

import Vue from 'vue'
import Vuetify from 'vuetify'
import 'vuetify/dist/vuetify.min.css'

Vue.use(Vuetify)

const opts = {}

export default new Vuetify(opts)

Now you should be all set to start using Vuetify components. Source: https://vuetifyjs.com/en/getting-started/quick-start/

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

How can you receive a file through AJAX response?

I have a standard Ajax function that I regularly use to call a specific function within my node.js server. This particular function is responsible for retrieving a file (usually in xls format) from the server and streaming it back to the client. Below is ...

Guide to moving a 3D model and initiating animation in threejs when a key is pressed

In the midst of a project where a person (gltf object) walks based on key presses, I have successfully updated the object position accordingly. However, I'm encountering difficulty in rotating the object when the left/right keys are pressed and ensur ...

Encountered an issue while attempting to deploy my app on Heroku: received the error message "The requested resource does not have the 'Access-Control-Allow-Origin' header"

Hi fellow developers, I'm currently facing an issue while trying to upload a simple app to my Herokuapp. Every time I attempt to log in or sign up and establish a connection with the back-end, I encounter the following CORS error: "Access to fetch at ...

The transformation of a Blender model in THREE.js results in a completely new and distinct

I have a Blender model that I'm trying to integrate into my website using THREE.js, but I'm encountering issues with the GLTF file rendering. The model appears broken with missing elements, misplaced objects, and incorrect lighting. I've tes ...

Creating a dynamic table in AngularJS with rotating values for rows and columns

I am seeking assistance in creating a table with a custom number of rows and columns. The table should have two input fields for specifying the number of rows and columns, and upon submission, the table should dynamically adjust to display the specified nu ...

Using axios to make a request to a REST API

I recently developed a Rest API using express to interact with mongodb. Testing it with postman has been successful so far. However, when I attempted to integrate the api with a basic web app created in vue and used axios to get a response from the api, ...

Synchronous async routes in Node Express

My express server requires fetching data from multiple external sources for each request, with the logic separated into various routers (some of which are not under my control). These routers operate independently, eliminating the need for one to wait on ...

JavaScript personalized video controls. Silence the video by manipulating the input range element

As a newcomer to javascript, I am working on creating custom video controls using js. One issue I am facing is with a span element that contains a mute/unmute icon. When I hover over this span element, a child element appears with an input range bar for ad ...

Nuxt failing to generate dist folder

Using docker-compose, I am building and running an SSR Nuxt.JS application with the web server being nginx. The issue arises when attempting to use nginx reverse proxy because the directory dist is not created in /app/. Below is my Dockerfile: FROM node:1 ...

Why aren't Material UI v5 styles being applied to the class?

I have been attempting to customize the MUI slider by applying styles using the className prop. However, I am facing an issue where the styles assigned to the main class are not being applied, but other styles such as the 'hover' state are workin ...

JavaScript: Passing the "this" object in an AJAX request situation

Here is the code snippet I am working with: $(function(){ $("#CASA").click(function(){ rsExecute("rs/rs_luci.php","premi",1,function(cc){}); var col=$( this ).css( "background-color" ); se ...

How can I create an admin layout overlay in AngularJS?

Hi there, I have a question regarding using angularJS in an application we are currently developing at work. We need to implement an "overlay" admin style panel. For example, refer to this image: In the first scenario, the URL is "myapp.com/#/works". To ...

Eliminating the table header in the absence of any rows

I have successfully implemented a Bootstrap table in my React application, where users can add or delete rows by clicking on specific buttons. However, I want to hide the table header when there are no rows present in the table. Can anyone guide me on how ...

Prevent altering client values via developer tools

Our application is built using HTML5, the Foundation framework by ZURB, and AngularJS. We are seeking a way to prevent users from accessing and changing the values of our Angular objects (specifically scope variables) through the developer tool console. ...

Using the outer ng-repeat's object property to filter nested ng-repeat items

I'm currently working on nesting two ng-repeats with two separate JSON files. The goal is to filter the second ng-repeat based on parameters from the first ng-repeat. The first JSON file, $scope.matches, includes information about each match in the W ...

Storing a token in NodeJS using JavaScript

We currently have a mobile single-page application built using HTML/CSS/NodeJS. The functionality of this app requires numerous API calls, all of which require a bearer token for authorization purposes. This bearer token is simply a string value that we ge ...

Unique column arrangement specifically designed for the initial row within the loop

My webpage features a layout that showcases 4 images on each row. However, I am looking to create a special first row with a unique column configuration compared to the rest of the rows. Here is an example of what I have in mind: https://i.sstatic.net/Rs ...

Excessive white space at the bottom of a floated image within a small parent element

I need help with styling a page that will only be viewed on mobile Safari. The HTML markup is as follows: <blockquote> <p><img src="..."/> A paragraph...</p> <p>...</p> ... </blockquote> Here is the CSS u ...

I'm looking to design a navbar similar to the one in the provided link, and I'd like it to appear when scrolling

I'm struggling to figure out how this particular navbar was created. How can I add a navlist for Videos and make the navbar visible upon scrolling? Are there any resources, articles, or hints to help me get started with this? LINK - ...

Tips for customizing bootstrap's fixed navbar-default to ensure that the list items align downwards:

Is it possible to customize the bootstrap fixed navbar-default so that the li elements align downward instead of at the top? If you have any corrections or custom solutions, I'd love to see them! Feel free to share your code on platforms like CodePen, ...