Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to deprecate a sass/scss mixin?

Tags:

sass

When maintaining and updating the mixins for a large team of developers, is it possible to deprecate mixins so that they throw some sort of warning when the styles are compiled?

I do not simply want to remove the deprecated mixins as it will take some time to remove all the current uses, but it'd be nice to warn the other developers that this is being removed if they attempt to use it.

like image 389
quoo Avatar asked Oct 03 '12 17:10

quoo


People also ask

What is the difference between a mixin and inheritance in SCSS?

@mixin is used to group css code that has to be reused a no of times. Whereas the @extend is used in SASS to inherit(share) the properties from another css selector. @extend is most useful when the elements are almost same or identical.

What is the use of mixin in SCSS?

Sass Mixins The @mixin directive lets you create CSS code that is to be reused throughout the website. The @include directive is created to let you use (include) the mixin.

What is @content in sass?

The @content, aka content directive, is “simple” in that it provides a way to reduce repetitive code, allowing for reuse and easier changes throughout the codebase.


1 Answers

You can use the @warn directive for this. From the SASS documentation:

The @warn directive prints the value of a SassScript expression to the standard error output stream. It’s useful for libraries that need to warn users of deprecations or recovering from minor mixin usage mistakes.

You'd use it like this:

@mixin old-mixin {
    @warn "This old mixin is deprecated!";

    // mixin definition here
}
like image 67
hopper Avatar answered Sep 28 '22 01:09

hopper