Skip to content

Commit 3adad12

Browse files
committed
Add ignore_empty_cache option for saving memory
1 parent 0ac5640 commit 3adad12

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ The `tailwind_merge` config is an object with several keys:
189189
tailwind_merge_config = {
190190
# ↓ *Optional* Define how many values should be stored in cache.
191191
cache_size: 500,
192+
# ↓ *Optional* Enable or disable caching nil values.
193+
ignore_empty_cache: true,
192194
# ↓ *Optional* modifier separator from Tailwind config
193195
separator: ":",
194196
# ↓ *Optional* prefix from Tailwind config

lib/tailwind_merge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def initialize(config: {})
2626
end
2727

2828
@class_utils = TailwindMerge::ClassUtils.new(@config)
29-
@cache = LruRedux::Cache.new(@config[:cache_size])
29+
@cache = LruRedux::Cache.new(@config[:cache_size], @config[:ignore_empty_cache])
3030
end
3131

3232
def merge(classes)

lib/tailwind_merge/config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ module Config
8484

8585
DEFAULTS = {
8686
cache_size: 500,
87+
ignore_empty_cache: true,
8788
separator: ":",
8889
theme: {
8990
"colors" => [IS_ANY],

test/test_config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def test_default_config_has_correct_types
77
config = TailwindMerge::Config::DEFAULTS
88

99
assert_equal(500, config[:cache_size])
10+
assert(config[:ignore_empty_cache])
1011
refute(config[:nonexistent])
1112
assert_equal("block", config[:class_groups]["display"].first)
1213
assert_equal("auto", config[:class_groups]["overflow"].first["overflow"].first)

0 commit comments

Comments
 (0)