sass Extend / Inheritance Optional Extends


Sometimes, you may want an @extend to be optional, and not require the specified class to exist in your code.

  @extend .message !optional
  background: red

This will result in the following CSS:

.message-important {
  background: red;

Disclaimer: This is useful during development when you may not have all of your code written yet and don't want errors, but it should probably be removed in production because it could lead to unexpected results.