Skip to content

Instantly share code, notes, and snippets.

@adamwathan
Last active December 5, 2016 06:58
Show Gist options
  • Save adamwathan/b2fbd39ca3e9a94f511b to your computer and use it in GitHub Desktop.
Save adamwathan/b2fbd39ca3e9a94f511b to your computer and use it in GitHub Desktop.
Importing class mixins by reference

This is the workflow I really love with Less that's missing in Sass. Killer way to use a library like Bootstrap without coupling any of your markup to Bootstrap itself.

Import a bunch of vendor styles by reference only, mix in the classes you want to keep into your own aliases, no vendor class names end up in your compiled CSS.

Sass doesn't support reference import or the ability to mixin a class, only a mixin.

// Vendor less
.btn {
  // a bunch
  // of
  // styles
}

// My Less
@import (reference) "buttons.less";

.my-button {
  .btn;
}

// Rendered CSS
.my-button {
  // a bunch
  // of
  // styles
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment