Vite eliminates the need to import formats like `import foo from "./assets/foo.svg?component"`

I am facing an issue with vite-svg-loader + vue + ts. When I try to import an svg into a vue component, the import gets automatically deleted as it is deemed unused.

I use WebStorm and have checked my settings (eslint), but they are turned off and I cannot figure out the problem.

Here is my vite-config:

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'

import svgLoader from 'vite-svg-loader'

export default defineConfig({
    base: "./",
    plugins: [vue(), svgLoader()]
})

Here is my vue component, however, whenever I save the file, the import gets deleted:
<template>

  <IconNavMain/>
</template>

<script lang="ts" setup>
import IconNavMain from "./assets/vue.svg?component"
</script>

Answer №1

This issue seems to be a bug specific to WebStorm. If you want to resolve it, try disabling the eslint rules related to not using imports.

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

What is the best way to generate a timesheet while linking each data entry to its corresponding date?

Looking to create a timesheet grid that shows the current week and the project being worked on, similar to this example: https://jsfiddle.net/ho9a8neq/ How can I use v-model to accurately send the value along with the corresponding date to a database? So ...

Customizing dropzone color while dragging an image in Angular

I have been using Angular and created an image input field. Within this input field, I implemented a dropzone that allows users to drag files into it. Is there a way for me to modify the background of the dropzone when a file is being dragged into it? Thi ...

Is there a specific write rate limit per connection on firestore?

My objective is to efficiently write 1000 documents to different paths using the Admin SDK in Cloud Functions. I am uncertain whether it would be more effective to use a for loop with database.set() executed 1000 times compared to using batch write twice ...

Unlocking the power of tailwind colors in javascript

I want to style my ApexCharts using my tailwind colors like red-500, but I cannot use CSS classes or the theme() function in a post-CSS context. Since I have already extended the default config, I cannot reference it either. One potential solution could ...

Facing a completely empty page after upgrading to vuejs 2.0

For me, upgrading my application to 2.0 has proven to be quite a challenge and I've spent hours trying to figure it out. In the past, I used vuejs within my application for certain functionalities, without treating it as a standalone vuejs application ...

Is there a way to adjust the path of a lazily loaded Webpack module?

I have a Vue application that utilizes Webpack and dynamic imports: // App.vue <template> <div> <button @click="isBtnClicked = true">Load lazy component</button> <LazyComponent v-if="isBtnClicked" /& ...

"Fixing VueJS axios issue: receiving 401 error for unauthorized POST request

I am having trouble sending a POST request with authorization to my REST api. Despite having CORS enabled on the server and everything working fine in Postman, I keep receiving an "unauthorized" error. Here is the code snippet I am using: axios . ...

Tips for transferring information from a Vue instance to a Vue component?

I am working with a Vue instance that includes two components. The goal is to have the template of the first component hidden when the user clicks on a button in the second component. Below is the code snippet: <div id="app"> <mycomp-one :ac ...

The Fusion of Apollo GraphQL Server and TypeScript: A Match Made

Lately, I've been immersed in a project that utilizes the node.js + express + typescript + Apollo server stack. During my research on Apollo client, I came across the TypeScript section, but surprisingly found little information regarding TypeScript f ...

employing constructor objects within classes

I am attempting to utilize a class with a constructor object inside another class. How should I properly invoke this class? For example, how can I use Class 1 within Class 2? Below is an instance where an object is being created from a response obtained f ...

Differences between Vue.js onMounted and watching refsVue.js offers

When it comes to calling a function that requires an HTMLElement as an argument, the element in question is rendered within my page template and therefore I need to ensure it is actually in the DOM before making the call. Two potential methods for waiting ...

Transferring information from blade to vue component in Vue/Laravel

Hey there, I'm currently diving into the world of Vue and trying to grasp its concepts. One thing that's been boggling my mind is how to tweak a component I've created for a create form so it can also be utilized for an edit form. Specifical ...

Discovering the element within an array using the post method in TypeScript

When I log in to the app, it sends me a JSON file with my user permissions like this: {"StatusCode":0,"StatusMessage":"Authenticated Successfully", "Token":"eyJhbGciOiJIUzI1NiIs", "StatusDescription":{ "Role":"admin", "Permissions":["homeb ...

Utilize the backup content in the slot only when the specified condition is satisfied

Is there a way to achieve the following scenario: Imagine we have a component with a slot, and a fallback content already set. When using this component elsewhere, I want it to act like this: <TheComponent> <template v-slot:name="{ data }"> ...

Enhance TypeScript in WebStorm: Update or Upgrade the bundled version

What is the best way to update or upgrade the default version? https://i.sstatic.net/hQFUd.png Important note: I prefer not to manually modify and switch to a custom version like: https://i.sstatic.net/wejP7.png ...

When the function is executed, the error message "obtaining ID

As I attempt to remove items from a group and automatically delete the group if there are no items left, I encounter an error in Vue indicating that 'id' is not defined. This seems puzzling to me because it should have already completed the opera ...

Sorting through a collection of objects using various criteria in typeScript

Hello team, I have an array of objects that looks like this: data = [ { name: "Pork", category: "Food", subcategory: "Meat" }, { name: "Pepper", category: "Food", subcategory: "Vegetables" }, ...

Error: Attempting to access the 'tokenType' property of an undefined object is not allowed

We encountered an error while attempting to embed a report using the Power BI Angular library. TypeError: Cannot read properties of undefined (reading 'tokenType') at isSaaSEmbedWithAADToken (reportEmbed?navContentPaneEnabled=false&uid=am ...

A guide on integrating array map with a v-for loop in Vue

Struggling to understand how to implement a loop within another loop in Vue? This task might seem simple with React, but Vue presents its own challenges when it comes to using loops with arrays in templates/JSX. The input data follows a specific format fr ...

Alert: Every child within a list must be assigned a distinct "key" property in React.js

After reading the article on looping inside React JSX, I decided to enhance my code by rendering components through a loop. However, an issue has arisen in the form of a warning message: Warning Each child in a list should have a unique "key" pro ...