Skip to content

[BUG] SCSS with & class modifier is stripped from compiled styles #17248

@dualjack

Description

@dualjack

Describe the bug

One of our clients insisted on using single class selectors.
I will not debate if it's reasonable or not, but this is actually a bug.

<div class="root">
	<p class="root__child">1</p>
	<p class="root__child">2</p>
	<p class="root__child">3</p>
	<p class="root__child">4</p>
</div>

<style lang="scss">

	.root {

		/** This is marked as unused -- cut off from compiled CSS */
		&__child {
			color: red;
		}
	}
	
</style>

The result of compiled SCSS should be:

Image

https://sass-lang.com/playground/#eJwzNNQrys8vUajmUgACtfj45IzMnBQoFwSS83Pyi6wUilJTrMFitVy1AGyCDYQ=

Reproduction

Svelte playground:
https://svelte.dev/playground/6143b525639143f5ab2044e18961e8d3?version=5.44.1

Sass playground:
https://sass-lang.com/playground/#eJwzNNQrys8vUajmUgACtfj45IzMnBQoFwSS83Pyi6wUilJTrMFitVy1AGyCDYQ=

Logs

System Info

Svelte 5.44.1

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions