最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vue.js - PhpStorm marking CSS selector in Vue as unused - Stack Overflow

programmeradmin0浏览0评论

I hope this question is not too broad.

Moving away from SASS while upgrading to Tailwind 4, I removed the lang=scss attributes from my <style scoped> tags in .vue files.

When removing the scss compiler reference, selectors only referenced in JS are not recognised as "used" anymore. This is already the case before switching to Tailwind 4.

Does anyone out there know if this might rather have to do with PhpStorm/WebStorm settings, Vite configuration, Vue or something else?

I have checked PhpStorm Setting

  • Languages & Frameworks > Style Sheets
  • Editor > Inspections > CSS > Unused selectors (I don't want to switch it off)

Minimal code example

<script setup lang="ts">
const {
  size = 'sm',
} = defineProps<{
  size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl',
}>()
</script>

<template>
  <span :class="[size]" class="icon" />
</template>

<style scoped>
.sm { /* <-- marked as unused (greyed out) after removing scss compiler reference */
  height: 16px;
  width: 16px;

  &.icon { /* <-- still marked as used, presumably because it is directly referenced in HTML */
    font-size: 10px;
  }
}
</style>
发布评论

评论列表(0)

  1. 暂无评论