condenser 1.2 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/condenser/asset.rb +69 -35
  3. data/lib/condenser/build_cache.rb +22 -9
  4. data/lib/condenser/context.rb +9 -25
  5. data/lib/condenser/helpers/parse_helpers.rb +8 -1
  6. data/lib/condenser/manifest.rb +3 -1
  7. data/lib/condenser/pipeline.rb +8 -3
  8. data/lib/condenser/processors/babel_processor.rb +9 -15
  9. data/lib/condenser/processors/css_media_combiner_processor.rb +81 -0
  10. data/lib/condenser/processors/js_analyzer.rb +41 -8
  11. data/lib/condenser/processors/node_processor.rb +1 -0
  12. data/lib/condenser/processors/purgecss_processor.rb +6 -4
  13. data/lib/condenser/processors/rollup_processor.rb +38 -36
  14. data/lib/condenser/resolve.rb +27 -6
  15. data/lib/condenser/templating_engine/ejs.rb +1 -1
  16. data/lib/condenser/transformers/dart_sass_transformer.rb +285 -0
  17. data/lib/condenser/transformers/jst_transformer.rb +67 -17
  18. data/lib/condenser/transformers/sass/functions.rb +133 -0
  19. data/lib/condenser/transformers/sass/importer.rb +48 -0
  20. data/lib/condenser/transformers/sass.rb +4 -0
  21. data/lib/condenser/transformers/sass_transformer.rb +124 -281
  22. data/lib/condenser/transformers/svg_transformer/base.rb +26 -0
  23. data/lib/condenser/transformers/svg_transformer/tag.rb +54 -0
  24. data/lib/condenser/transformers/svg_transformer/template.rb +151 -0
  25. data/lib/condenser/transformers/svg_transformer/template_error.rb +2 -0
  26. data/lib/condenser/transformers/svg_transformer/value.rb +13 -0
  27. data/lib/condenser/transformers/svg_transformer/var_generator.rb +10 -0
  28. data/lib/condenser/transformers/svg_transformer.rb +19 -0
  29. data/lib/condenser/version.rb +1 -1
  30. data/lib/condenser.rb +17 -5
  31. data/test/cache_test.rb +157 -18
  32. data/test/dependency_test.rb +51 -2
  33. data/test/manifest_test.rb +34 -0
  34. data/test/minifiers/terser_minifier_test.rb +0 -1
  35. data/test/minifiers/uglify_minifier_test.rb +0 -1
  36. data/test/postprocessors/css_media_combiner_test.rb +107 -0
  37. data/test/postprocessors/purgecss_test.rb +62 -0
  38. data/test/preprocessor/babel_test.rb +703 -298
  39. data/test/preprocessor/js_analyzer_test.rb +35 -2
  40. data/test/processors/rollup_test.rb +50 -20
  41. data/test/resolve_test.rb +18 -9
  42. data/test/server_test.rb +15 -10
  43. data/test/templates/ejs_test.rb +2 -11
  44. data/test/templates/erb_test.rb +0 -5
  45. data/test/test_helper.rb +8 -3
  46. data/test/transformers/dart_scss_test.rb +139 -0
  47. data/test/transformers/jst_test.rb +165 -21
  48. data/test/transformers/scss_test.rb +14 -0
  49. data/test/transformers/svg_test.rb +40 -0
  50. metadata +23 -6
  51. data/lib/condenser/transformers/sass_transformer/importer.rb +0 -50
@@ -4,7 +4,6 @@ class UglifyMinifierTest < ActiveSupport::TestCase
4
4
 
5
5
  def setup
6
6
  super
7
- @env.unregister_preprocessor('application/javascript', Condenser::BabelProcessor)
8
7
  @env.unregister_exporter('application/javascript', Condenser::RollupProcessor)
9
8
  end
10
9
 
@@ -0,0 +1,107 @@
1
+ require 'test_helper'
2
+
3
+ class MediaCombinerTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ super
7
+ @env.register_postprocessor('text/css', Condenser::CSSMediaCombinerProcessor)
8
+ @env.unregister_minifier('text/css')
9
+ end
10
+
11
+ test 'combine media queries' do
12
+ file 'main.css', <<~CSS
13
+ .test{
14
+ display: block;
15
+ }
16
+ @media only screen and (max-width: 100px) {
17
+ .test {
18
+ display: inline-block;
19
+ color: blue;
20
+ }
21
+ }
22
+ @media only screen and (max-width: 500px) {
23
+ .test {
24
+ display: inline;
25
+ }
26
+ }
27
+
28
+ .test2{
29
+ display: block;
30
+ }
31
+ @media only screen and (max-width: 100px) {
32
+ .test2 {
33
+ display: inline-block;
34
+ }
35
+ }
36
+ CSS
37
+
38
+ assert_exported_file 'main.css', 'text/css', <<~FILE
39
+ .test{
40
+ display: block;
41
+ }
42
+
43
+
44
+
45
+ .test2{
46
+ display: block;
47
+ }
48
+ @media only screen and (max-width: 100px) {
49
+ .test {
50
+ display: inline-block;
51
+ color: blue;
52
+ }
53
+
54
+ .test2 {
55
+ display: inline-block;
56
+ }
57
+ }@media only screen and (max-width: 500px) {
58
+ .test {
59
+ display: inline;
60
+ }
61
+ }
62
+ FILE
63
+ end
64
+
65
+ test 'single line css' do
66
+ file 'main.css', <<~CSS
67
+ .test{display: block;} @media only screen and (max-width: 100px) {.test {display: inline-block;}}@media only screen and (max-width: 500px) {.test {display: inline;}}.test2{display: block;}@media only screen and (max-width: 100px) {.test2 {display: inline-block;}}
68
+ CSS
69
+
70
+ assert_exported_file 'main.css', 'text/css', <<~FILE
71
+ .test{display: block;} .test2{display: block;}@media only screen and (max-width: 100px) {.test {display: inline-block;}.test2 {display: inline-block;}}@media only screen and (max-width: 500px) {.test {display: inline;}}
72
+ FILE
73
+ end
74
+
75
+
76
+ test 'keyframes' do
77
+ file 'main.css', <<~CSS
78
+ .trobber {
79
+ animation: throb 1s infinite;
80
+ }
81
+ @keyframes throb {
82
+ 0% {
83
+ opacity: 1;
84
+ }
85
+ 100%{
86
+ opacity: 0;
87
+ }
88
+ }
89
+ CSS
90
+
91
+ assert_exported_file 'main.css', 'text/css', <<~FILE
92
+ .trobber {
93
+ animation: throb 1s infinite;
94
+ }
95
+ @keyframes throb {
96
+ 0% {
97
+ opacity: 1;
98
+ }
99
+ 100%{
100
+ opacity: 0;
101
+ }
102
+ }
103
+ FILE
104
+ end
105
+
106
+
107
+ end
@@ -79,5 +79,67 @@ class PurgeCSSTest < ActiveSupport::TestCase
79
79
  }
80
80
  FILE
81
81
  end
82
+
83
+ test 'purge from html with class with /' do
84
+ file 'main.css', <<~CSS
85
+ .test{
86
+ display: block;
87
+ }
88
+ .test2-1\\/2{
89
+ display: inline;
90
+ }
91
+ CSS
92
+ file 'index.html', <<~HTML
93
+ <div class="test2-1/2"></div>
94
+ HTML
95
+
96
+ assert_exported_file 'main.css', 'text/css', <<~FILE
97
+ .test2-1\\/2{
98
+ display: inline;
99
+ }
100
+ FILE
101
+ end
102
+
103
+ test 'purge from html with nested tag' do
104
+ file 'main.css', <<~CSS
105
+ .test pre{
106
+ display: block;
107
+ }
108
+ CSS
109
+ file 'index.html', <<~HTML
110
+ <div class="test">
111
+ <pre>Test</pre>
112
+ </div>
113
+ HTML
114
+
115
+ assert_exported_file 'main.css', 'text/css', <<~FILE
116
+ .test pre{
117
+ display: block;
118
+ }
119
+ FILE
120
+ end
121
+
122
+ test 'purge from html with nested tags' do
123
+ file 'main.css', <<~CSS
124
+ code {
125
+ background: gray;
126
+ }
127
+ pre code{
128
+ background: none;
129
+ }
130
+ CSS
131
+ file 'index.html', <<~HTML
132
+ <pre><code>Test</code></pre>
133
+ HTML
134
+
135
+ assert_exported_file 'main.css', 'text/css', <<~FILE
136
+ code {
137
+ background: gray;
138
+ }
139
+ pre code{
140
+ background: none;
141
+ }
142
+ FILE
143
+ end
82
144
 
83
145
  end