Unable to display Vuetify build in Web component style

I'm currently working on an app that utilizes Vue and Vuetify with Web components. However, after adding Vuetify as a web component, I noticed that the CSS styles from Vuetify are no longer visible. I attempted to include

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css">
in the demo.html file, but this did not resolve the issue. You can find my repository at vuetify as web component. I have also added
transpileDependencies: [ 'vuetify' ]
to my vue.config.js, however, this has not fixed the problem either. It's important to note that the Vuetify styles are still not functioning properly. I have explored the following resources:

  1. v-aoutocomplete not working with wc
  2. Vuetify: external page CSS breaks Vuetify's component style
  3. Custom Web Component image not showing

The steps taken and various options I've tried are outlined in the readme.MD file of my repository. Any guidance on how to successfully include Vuetify styles in a Web Component would be greatly appreciated.

Answer №1

What is the problem at hand?

During the build process of a web component using vue-cli, the system overlooks the main.js file and opts for using entry-wc.js, following the official documentation which states:

When building a Webcomponent or Library, the entry point is not main.js, but an entry-wc.js file...
. This leads to issues where by default, vue-cli uses src/App.vue as the entry component, causing imported components like vuetify into App.vue to render one level below.

Potential Solution 1

To resolve this issue, remove all instances of vuetify's components from App.vue and place them one level lower in the hierarchy.

<template>
  <HelloWorld/> <!-- v-app / v-main / v-btn go inside HelloWorld -->
</template>

<script>
import vuetify from '@/plugins/vuetify'
import HelloWorld from './components/HelloWorld';

export default {
  name: 'App',
  vuetify,
  components: {
    HelloWorld,
  },
};
</script>

<style> 
  @import 'https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css';
</style>

Potential Solution 2

If preferred, keep vuetify's components within App.vue by eliminating the import vuetify... statement and <style> @Import.... Instead, create a separate 'wrapping' component (e.g. Wrap.vue), import vuetify and its styles into this new component, and then import App.vue. Add the new component name to the CLI command:

...
"wcin": "vue-cli-service build --target wc --inline-vue --name my-element 'src/Wrap.vue'"
...

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

AngularJs fails to render CSS styles

I'm encountering a small issue with my angularJS code. I am attempting to showcase JSON data that includes both CSS and HTML code. However, on my website, all that is displayed is a hard-coded form of HTML and CSS (resembling the code below). I have t ...

How to retrieve the changing input value in ReactJS using Jquery/JS

I have a form in WordPress with two input range sliders. The form calculates the values of these sliders and displays the result as shown below: <input data-fraction-min="0" data-fraction="2" type="hidden" data-comma=" ...

Inject the result.php file into a bootstrap modal using AJAX

Disclaimer: After searching through various stackoverflow posts within the last 3 days, I have not been able to find a precise answer to my question. Please read before providing a link to an already answered query. Issue I am facing a problem where the ...

The error persists in Ajax requests despite the correct usage of json_encode and everything functioning correctly

In the realm of e-commerce, I have successfully implemented an AJAX request to dynamically add and remove items from the cart. Interestingly enough, every time the jQuery script is executed, everything seems to be working seamlessly. The server always resp ...

Locate the generated ID of the inserted child when saving the parent in MongoDB

If I have a document representing a post with comments like the one below: { "_id": "579a2a71f7b5455c28a7abcb", "title": "post 1", "link": "www.link1.com", "__v": 0, "comments": [ { "author": "Andy", "body": "Wis ...

Issue with Laravel Sanctum and Vue CLI not properly storing cookiesalternatively:Cookies

Currently, I have Laravel 8 installed on a remote server, and my aim is to authenticate from the Vue CLI running on localhost using Sanctum. The issue arises when I submit the login form as it confirms authentication but fails to set the cookies in the bro ...

Guide to activating a watcher once the page finishes loading

One of my challenges involves a watcher calling a method: watch: { 'list.items' (n, o) { this.doSomething() } } Every time the page loads, new values are added to list.items like this: methods: { fetchLists(){ axios.get('/ ...

Spring Boot fails to recognize path variable data sent from Angular

When working with Angular 7, I encountered a situation where I needed to pass a value from the service class of Angular. Here is how I achieved it: executeHelloWorldBeanServiceWithPathVariable(name){ console.log("name coming from here"+name); retu ...

Conflict between Javascript and jQuery plugin discovered in testing environment

I've been trying to implement the smooth scroll functionality from smoothdivscroll.com/#quickdemo on my website, but I'm facing a JavaScript conflict. It seems to work fine on a test page at , but it's not functioning on the live page at viw ...

Storing the output of asynchronous promises in an array using async/await technique

I am currently working on a script to tally elements in a JSON file. However, I am encountering difficulty in saving the results of promises into an array. Below is the async function responsible for counting the elements: async function countItems(direct ...

Customized queries based on conditional routes - expressjs

Can we customize queries based on optional routes? app.get('/:category/:item?', function (req, res) { var category = req.params.category; var item = req.params.item; var sqlQuery = 'SELECT * FROM items WHERE category = ? AND item = ?&a ...

Using Vue.js to update a variable in a parent component that is nested multiple layers deep

Check out my cool Vue Instance: const myApp = new Vue({ el: '#my-app', data() { return { trigger: true } }, components: { ChildComponentOne, ChildComponentTwo }, router, store, ...

I am facing an issue where Bootstrap button classes are duplicating when I inspect the code. How can I resolve this

Can anyone help me with an issue I am facing with a Bootstrap button? Despite using only the btn btn-default classes, when inspecting it in Chrome, multiple classes are being displayed on the button. I'm unable to figure out why this is happening and ...

Utilizing jQuery to load form(s), submit data via POST method, and fetch results without refreshing the

After conducting thorough research, I have been unsuccessful in implementing any of the solutions I have come across. It seems like I am close to a solution, but there may be something crucial that I am missing... A question similar to mine was asked on t ...

When attempting to send data using jQuery to PHP, an issue arises where PHP is unable to receive the information, resulting in an undefined variable

Has anyone successfully sent data from an HTML select to a PHP file using jQuery? I've tried multiple solutions suggested here, but none seem to be working for me. Below is the code I'm using: <select id="city" name="city" > <optgro ...

When utilizing AJAX within a for loop, the array position may not return the correct values, even though the closure effectively binds the scope of the current value position

Is this question a duplicate of [AJAX call in for loop won't return values to correct array positions? I am following the solution by Plynx. The issue I'm facing is that the closure fails to iterate through all elements in the loop, although the ...

Ensure the computed variable is always up-to-date using Firebase in VueJS

After a successful sign-in through Firebase authentication, I need to update a navigation link. The user login changes are managed within the created hook using .onAuthStateChanged() data () { return { user: null, additionaluserinfo: nul ...

RadRotator fails to resize properly when browser window is resized

I'm currently attempting to adjust the size of this control when the browser is resized. I searched through forums for a solution before posting my question. I came across a JavaScript function (unfortunately, it's not working). <script t ...

Utilizing the same uuid twice along with Vuex and the unique identifier generation tool uuidv4

Within my vuex store, there is a function to create a post. This function generates a json Object containing a unique uuid using uuidv4(). However, I have noticed that if I execute the function multiple times, the uuid remains the same each time (unless I ...

What is the best method for retrieving options based on a data attribute?

All <option> elements in a <select> have data-value attributes set (example provided below). Upon page load, I must find and iterate through the values of all <option> elements to pick out one that suits further processing. We plan on us ...