├── LICENSE.md ├── README.md ├── _sass-require.scss ├── bower.json └── example ├── .sass-cache ├── 7e1aae36736bb608be9f2d347d3f730d09429534 │ └── _sass-require.scssc └── a022c0f9b2215a8bbb90dbe28f6a40d785f54d9a │ ├── _dep-object.scssc │ ├── _object-one.scssc │ ├── _object-two.scssc │ └── main.scssc ├── _dep-object.scss ├── _object-one.scss ├── _object-two.scss ├── main.css ├── main.css.map └── main.scss /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Adam Bulmer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a small mixin to only include a scss object once. 2 | 3 | I recently discovered an issue with bower components and shared dependencies. 4 | If you have multiple bower components that depend on a shared component 5 | when the scss is compiled these styles will be outputted twice duplicating 6 | the amount of code. 7 | 8 | This mixin solves this by outputting the code only once. You can import sass-require in each 9 | bower_component, it won't care. 10 | 11 | ## Install 12 | `bower install sass-require --save` 13 | 14 | ## Usage 15 | 16 | Define an scss object 17 | 18 | ``` 19 | @import 'bower_components/sass-require'; 20 | 21 | @include define('test-object') { 22 | 23 | .object-code { 24 | display: block; 25 | } 26 | 27 | } 28 | ``` 29 | 30 | See the example folder but example output code. 31 | -------------------------------------------------------------------------------- /_sass-require.scss: -------------------------------------------------------------------------------- 1 | @if not global-variable-exists(sass-require__components) { 2 | $sass-require__components: () !global; 3 | } 4 | 5 | @mixin define($name) { 6 | @if (index($sass-require__components, $name) == null) { 7 | $sass-require__components: append($sass-require__components, $name) !global; 8 | @content; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sass-require", 3 | "version": "1.0.2", 4 | "authors": [ 5 | "Adam Bulmer " 6 | ], 7 | "description": "Sass Require, only import your object once", 8 | "main": "_sass-require.scss", 9 | "keywords": [ 10 | "Sass", 11 | "Sass", 12 | "Require", 13 | "Scss", 14 | "Import" 15 | ], 16 | "license": "MIT", 17 | "homepage": "http://mintuz.com", 18 | "ignore": [ 19 | "**/.*", 20 | "node_modules", 21 | "bower_components", 22 | "test", 23 | "tests" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /example/.sass-cache/7e1aae36736bb608be9f2d347d3f730d09429534/_sass-require.scssc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintuz/sass-require/e4e0c78da10ae65febc490586e8e8341e03dfa13/example/.sass-cache/7e1aae36736bb608be9f2d347d3f730d09429534/_sass-require.scssc -------------------------------------------------------------------------------- /example/.sass-cache/a022c0f9b2215a8bbb90dbe28f6a40d785f54d9a/_dep-object.scssc: -------------------------------------------------------------------------------- 1 | 3.4.10 (Selective Steve) 2 | 9b90fdd3c7d23016570225d9dc08ae8a423edec8 3 | o:Sass::Tree::RootNode :@children[o:Sass::Tree::MixinNode: 4 | @nameI" define:ET: 5 | @args[o: Sass::Script::Tree::Literal : @valueo: Sass::Script::Value::String; I"dep-object; T: 6 | @type: string: @options{: 7 | @linei:@source_rangeo:Sass::Source::Range :@start_poso:Sass::Source::Position;i: @offseti: @end_poso;;i;i": 8 | @fileI"_dep-object.scss; T:@importero: Sass::Importers::Filesystem: 9 | @rootI";/Users/adambulmer/Projects/Flexdd/sass-require/example; T:@real_rootI";/Users/adambulmer/Projects/Flexdd/sass-require/example; T:@same_name_warningso:Set: 10 | @hash{:@filename@:@keywordso:Sass::Util::NormalizedMap:@key_strings{: @map{: @splat0:@kwarg_splat0;[o:Sass::Tree::RuleNode: 11 | @rule[I".dep-object; T:@parsed_ruleso:"Sass::Selector::CommaSequence: @members[o:Sass::Selector::Sequence;+[o:#Sass::Selector::SimpleSequence ;+[o:Sass::Selector::Class;I"dep-object; T;i; 0: @subject0: @sourceso;;{;o; ;o;;i;i;o;;i;i;0;0;i; 0;i; 0:@selector_source_rangeo; ;o;;i;i;o;;i;i;@;@: 12 | @tabsi;[o:Sass::Tree::PropNode;[I" display; T; o; ; o; ; I" 13 | block; T;:identifier;@ ;i ;o; ;o;;i ;i;o;;i ;i;@;@;2i:@prop_syntax:new;[;i ;o; ;o;;i ;i;o;;i ;i;@;@:@name_source_rangeo; ;@:;o;;i ;i;@;@:@value_source_rangeo; ;o;;i ;i;@;;@;@;@ o;3;[I"background-color; T; o; ; o; ; I" 14 | black; T;;4;@ ;i 15 | ;o; ;o;;i 16 | ;i;o;;i 17 | ;i;@;@;2i;5;6;[;i 18 | ;o; ;o;;i 19 | ;i;o;;i 20 | ;i;@;@;7o; ;@K;o;;i 21 | ;i;@;@;8o; ;o;;i 22 | ;i;@L;@;@;@ ;i;o; ;@,;o;;i;i;@;@:@has_childrenT;@ ;i;o; ;o;;i;i;o;;i;i$;@;@;9T;@ :@templateI"g@include define('dep-object') { 23 | 24 | .dep-object { 25 | display: block; 26 | background-color: black; 27 | } 28 | 29 | }; T;i;o; ;o;;i;i;o;;i;i;@;@;9T;@ -------------------------------------------------------------------------------- /example/.sass-cache/a022c0f9b2215a8bbb90dbe28f6a40d785f54d9a/_object-one.scssc: -------------------------------------------------------------------------------- 1 | 3.4.10 (Selective Steve) 2 | 8a583d8d7bd54dc4b24df92a146d0b60f6ca30c8 3 | o:Sass::Tree::RootNode :@children[o:Sass::Tree::ImportNode :@imported_filenameI"dep-object:ET;[:@template0: 4 | @linei:@source_rangeo:Sass::Source::Range :@start_poso:Sass::Source::Position; i: @offseti: @end_poso;; i;i: 5 | @fileI"_object-one.scss; T:@importero: Sass::Importers::Filesystem: 6 | @rootI";/Users/adambulmer/Projects/Flexdd/sass-require/example; T:@real_rootI";/Users/adambulmer/Projects/Flexdd/sass-require/example; T:@same_name_warningso:Set: 7 | @hash{: @options{:@imported_file0o:Sass::Tree::MixinNode: 8 | @nameI" define; T: 9 | @args[o: Sass::Script::Tree::Literal : @valueo: Sass::Script::Value::String; I"object-one; T: 10 | @type: string;@; i; o; ;o;; i;i;o;; i;i";@ ;@:@filename@ :@keywordso:Sass::Util::NormalizedMap:@key_strings{: @map{: @splat0:@kwarg_splat0;[o:Sass::Tree::RuleNode: 11 | @rule[I".object-one; T:@parsed_ruleso:"Sass::Selector::CommaSequence: @members[o:Sass::Selector::Sequence;/[o:#Sass::Selector::SimpleSequence ;/[o:Sass::Selector::Class;I"object-one; T; i 12 | ;$0: @subject0: @sourceso;;{; o; ;o;; i;i;o;; i;i;0;0; i 13 | ;$0; i 14 | ;$0:@selector_source_rangeo; ;o;; i 15 | ;i;o;; i 16 | ;i;@ ;@: 17 | @tabsi;[o:Sass::Tree::PropNode;[I" display; T; o;; o;!; I" 18 | block; T;":identifier;@; i ; o; ;o;; i ;i;o;; i ;i;@ ;@;6i:@prop_syntax:new;[; i ; o; ;o;; i ;i;o;; i ;i;@ ;@:@name_source_rangeo; ;@@;o;; i ;i;@ ;@:@value_source_rangeo; ;o;; i ;i;@A;@ ;@;@o;7;[I"background-color; T; o;; o;!; I"red; T;";8;@; i ; o; ;o;; i ;i;o;; i ;i;@ ;@;6i;9;:;[; i ; o; ;o;; i ;i;o;; i ;i;@ ;@;;o; ;@Q;o;; i ;i;@ ;@;