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>
sizeprop is used as a class (some IDE's do understand that) and couple that with the TS compilation result - figure out all possible values of its type) and then mark any classes allowed by theose values as "used". I agree it would be nice for the IDE to be that smart but, in reality, these checks are much simpler: string searches/matches in<template>, unless someone writes a dedicated plugin for it (e.g: the Vue team).