Vue Multiselect has different styles in development environment compared to production environment

After including

<style src="vue-multiselect/dist/vue-multiselect.min.css">
in my Vue component, I noticed that the styles are applied when running npm run dev, but not when running npm run prod. How can I resolve this issue?

<template>
    <multi-select :id="id" v-model="value" :options="options" :multiple="multiple" :max="max"></multi-select>
</template>

<script>
    import multiSelect from 'vue-multiselect';
    export default {
        name: "my-multi-select",
        components: { multiSelect },
    }
</script>

<style src="vue-multiselect/dist/vue-multiselect.min.css"></style>

Answer №1

The issue at hand is related to the use of a relative path. To resolve this, you must add a reference to your src folder in order to instruct vue-cli to include it in the production build.

<style>
  @import './assets/styles/vue-multiselect.min.css';
</style>

In this context, the @ symbol signifies the src path. The organization and naming conventions within your folders are at your discretion.


UPDATE: An alternative approach would involve reinstalling the package using the following command:

npm install vue-multiselect@next --save

You could also import the package similarly to how you import the component:

import Multiselect from 'vue-multiselect'
import 'vue-multiselect/dist/vue-multiselect.min.css'

UPDATE 2: Create a vue.config.js file in the root directory with the following contents:

module.exports = {
        publicPath: './'
    };

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

Could this be a problem with synchronization? Utilizing Google Translate to link-translate terms

Trying to create a script that will show how a word changes through multiple translations using Google Translate, but struggling with Javascript. The problem I'm facing is hard to pinpoint: function initialize() { var word = "Hello"; var engl ...

The RemoveEventListener function seems to be malfunctioning within Angular2 when implemented with TypeScript

I am currently incorporating three.js into Angular2. The code I am using is quite straightforward, as shown below. this.webGLRenderer.domElement.addEventListener('mousedown', ()=>this.onMouseDown(<MouseEvent>event), false); this.webGLR ...

A guide on sorting JSON data with Javascript/jquery

I have a set of JSON data: {"X1":"3","X2":"34","Y1":"23","Y2":"23","Z1":"234","Z2":"43",...} My goal is to rearrange and group this data as follows: var newDataJson1 = { "X":{"X1":"3","X2":34}, "Y":{"Y1":"23","Y2":"23"}, ... } ALSO, I want to stru ...

What's the best way to link two http requests in AngularJS?

Currently, I am facing the challenge of chaining two http calls together. The first call retrieves a set of records, and then I need to fetch finance data for each individual record. flightRecordService.query().$promise.then(function (flightRecords) { $ ...

Firestore's get document method may cause an unmounted warning

I've been working on a React.js project that integrates with Firestore, and I ran into an issue where using the get method for fetching documents resulted in a "Can't perform a React state update on an unmounted component" warning. However, when ...

Ways to utilize a singular pathway in various situations?

In my Nuxt project, I have implemented an admin dashboard with a unique layout (sidebar) using <NuxtChild> to render child routes: Admin.vue <NuxtChild :key="$route.path" /> Simplified Routes: { path: "/admin", ...

Vuejs application is not producing the anticipated outcome when an ordered list contains an unordered list

Is there a way to nest an unordered list within an ordered list in vue 2? I've attempted <template> <div class="p-14"> <ol class="numberlist"> <li>An numbered list</li> <li>Cont ...

Adjust the minimum height and width when resizing the window

Apologies in advance if this has already been addressed, but I have tried solutions from other sources without success. My Objective: I aim to set the minimum height and width of a div based on the current dimensions of the document. This should trigger ...

in Vue.js, extract the style of an element and apply it to a different element

Currently, I am using VUE.js 2 in my project. Here is my website's DOM structure: <aside :style="{height : height()}" class="col-sm-4 col-md-3 col-lg-3">...</aside> <main class="col-sm-8 col-md-9 col-lg-9" ref="userPanelMainContents" ...

Vue.js - sortable table with search functionality and image display

A Vue.js component/view I created displays data in the following format: <tbody v-for="item in items"> <tr> <td width="15%"><img :src="item.image"></td> <td width="50%">{{item.name}}</td> <td>{{item.purc ...

JavaScript nested function that returns the ID of the first div element only upon being clicked

I am facing an issue with a function that returns the id of the first div in a post when an ajax call is made. The problem is that it repeats the same id for all subsequent elements or div tags. However, when the function is used on click with specified ...

Show a row of pictures with overflow capabilities

I am looking to develop my own image viewer that surpasses the capabilities of Windows. My goal is to design an HTML page featuring all my images laid out horizontally to maximize screen space. I also want the images to adjust in size and alignment as I z ...

Combining JavaScript objects with matching keys and values into an array

I'm currently working on merging JavaScript objects that share the same key. Specifically, I intend to use the "time" field as the key and include every "app" as a key with its corresponding "sum" value for each time entry. The other fields will not b ...

Global jQuery variables are unexpectedly coming back as "undefined" despite being declared globally

I need to save a value from a JSON object in a global variable for future use in my code. Despite trying to declare the country variable as global, it seems like it doesn't actually work. $.getJSON(reverseGeoRequestURL, function(reverseGeoResult){ ...

JavaScript is utilized to implement the k-means clustering algorithm, which demonstrates convergence yet lacks stability in its

Although I understand the concept of convergence, I am puzzled by the fact that the results vary each time the algorithm is refreshed, even when using the same dataset. Can someone point out where my methodology might be incorrect? I've been strugglin ...

Getting the response data from an XMLHttpRequest - Full guide with screenshots

Currently, I am working with autocomplete jQueryUI and have this code snippet: .autocomplete({ source: function( request, response ) { var results = $.getJSON( url, { term: extractLast( request.term ) }, response ); console.log(results); ...

Encountered an issue while implementing the post function in the REST API

Every time I attempt to utilize the post function for my express rest API, I encounter errors like the following. events.js:85 throw er; // Unhandled 'error' event ^ error: column "newuser" does not exist at Connection.parseE (/Use ...

What could be causing the "10 $digest error" to appear in my code?

My goal was to create a basic app that could detect the size of the browser and display it. But, I encountered an error message saying "Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!" app.controller('AppCtrl',function($win ...

Interactive HTML button capable of triggering dual functionalities

I am working on a project where I need to create a button using HTML that can take user input from a status box and display it on another page. I have successfully implemented the functionality to navigate to another page after clicking the button, but I ...

Customize the data attributes of Vuetify v-select options for added functionality

I am currently utilizing a v-autocomplete component to display items in a selector. Given that v-autocomplete is essentially just an enhanced version of v-select, I believe a solution for v-select would be applicable for v-autocomplete as well. Within my ...