condenser 1.2 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/condenser/asset.rb +69 -35
- data/lib/condenser/build_cache.rb +22 -9
- data/lib/condenser/context.rb +9 -25
- data/lib/condenser/helpers/parse_helpers.rb +8 -1
- data/lib/condenser/manifest.rb +3 -1
- data/lib/condenser/pipeline.rb +8 -3
- data/lib/condenser/processors/babel_processor.rb +9 -15
- data/lib/condenser/processors/css_media_combiner_processor.rb +81 -0
- data/lib/condenser/processors/js_analyzer.rb +41 -8
- data/lib/condenser/processors/node_processor.rb +1 -0
- data/lib/condenser/processors/purgecss_processor.rb +6 -4
- data/lib/condenser/processors/rollup_processor.rb +38 -36
- data/lib/condenser/resolve.rb +27 -6
- data/lib/condenser/templating_engine/ejs.rb +1 -1
- data/lib/condenser/transformers/dart_sass_transformer.rb +285 -0
- data/lib/condenser/transformers/jst_transformer.rb +67 -17
- data/lib/condenser/transformers/sass/functions.rb +133 -0
- data/lib/condenser/transformers/sass/importer.rb +48 -0
- data/lib/condenser/transformers/sass.rb +4 -0
- data/lib/condenser/transformers/sass_transformer.rb +124 -281
- data/lib/condenser/transformers/svg_transformer/base.rb +26 -0
- data/lib/condenser/transformers/svg_transformer/tag.rb +54 -0
- data/lib/condenser/transformers/svg_transformer/template.rb +151 -0
- data/lib/condenser/transformers/svg_transformer/template_error.rb +2 -0
- data/lib/condenser/transformers/svg_transformer/value.rb +13 -0
- data/lib/condenser/transformers/svg_transformer/var_generator.rb +10 -0
- data/lib/condenser/transformers/svg_transformer.rb +19 -0
- data/lib/condenser/version.rb +1 -1
- data/lib/condenser.rb +17 -5
- data/test/cache_test.rb +157 -18
- data/test/dependency_test.rb +51 -2
- data/test/manifest_test.rb +34 -0
- data/test/minifiers/terser_minifier_test.rb +0 -1
- data/test/minifiers/uglify_minifier_test.rb +0 -1
- data/test/postprocessors/css_media_combiner_test.rb +107 -0
- data/test/postprocessors/purgecss_test.rb +62 -0
- data/test/preprocessor/babel_test.rb +703 -298
- data/test/preprocessor/js_analyzer_test.rb +35 -2
- data/test/processors/rollup_test.rb +50 -20
- data/test/resolve_test.rb +18 -9
- data/test/server_test.rb +15 -10
- data/test/templates/ejs_test.rb +2 -11
- data/test/templates/erb_test.rb +0 -5
- data/test/test_helper.rb +8 -3
- data/test/transformers/dart_scss_test.rb +139 -0
- data/test/transformers/jst_test.rb +165 -21
- data/test/transformers/scss_test.rb +14 -0
- data/test/transformers/svg_test.rb +40 -0
- metadata +23 -6
- data/lib/condenser/transformers/sass_transformer/importer.rb +0 -50
@@ -4,8 +4,6 @@ class JSAnalyzerTest < ActiveSupport::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
super
|
7
|
-
@env.unregister_preprocessor 'application/javascript', Condenser::BabelProcessor
|
8
|
-
@env.register_preprocessor 'application/javascript', Condenser::JSAnalyzer
|
9
7
|
@env.unregister_minifier('application/javascript')
|
10
8
|
end
|
11
9
|
|
@@ -250,4 +248,39 @@ class JSAnalyzerTest < ActiveSupport::TestCase
|
|
250
248
|
assert_equal ['a.js', 'b.js'], asset.export_dependencies.map(&:filename)
|
251
249
|
end
|
252
250
|
|
251
|
+
test "dependency tracking for a export from" do
|
252
|
+
file 'c.js', <<~JS
|
253
|
+
function c() { return 'ok'; }
|
254
|
+
|
255
|
+
export {c}
|
256
|
+
JS
|
257
|
+
|
258
|
+
file 'b.js', <<~JS
|
259
|
+
export {c} from 'c';
|
260
|
+
|
261
|
+
JS
|
262
|
+
|
263
|
+
file 'a.js', <<~JS
|
264
|
+
import {c} from 'b'
|
265
|
+
|
266
|
+
console.log(c());
|
267
|
+
JS
|
268
|
+
|
269
|
+
asset = assert_file 'a.js', 'application/javascript'
|
270
|
+
assert_equal ['/a.js', '/b.js', '/c.js'], asset.all_export_dependencies.map { |path| path.delete_prefix(@path) }
|
271
|
+
end
|
272
|
+
|
273
|
+
test 'exporting a nested object' do
|
274
|
+
file 't.js', <<~JS
|
275
|
+
export default {
|
276
|
+
registry: {
|
277
|
+
boolean: true,
|
278
|
+
integer: 1
|
279
|
+
}
|
280
|
+
};
|
281
|
+
JS
|
282
|
+
|
283
|
+
asset = assert_file 't.js', 'application/javascript'
|
284
|
+
end
|
285
|
+
|
253
286
|
end
|
@@ -31,15 +31,14 @@ class RollupTest < ActiveSupport::TestCase
|
|
31
31
|
(function () {
|
32
32
|
'use strict';
|
33
33
|
|
34
|
-
// This function
|
35
|
-
|
36
|
-
function cube(x) {
|
34
|
+
// This function gets included
|
35
|
+
function cube ( x ) {
|
37
36
|
return x * x * x;
|
38
37
|
}
|
39
38
|
|
40
|
-
console.log(cube(5)); // 125
|
39
|
+
console.log( cube( 5 ) ); // 125
|
41
40
|
|
42
|
-
}()
|
41
|
+
})();
|
43
42
|
FILE
|
44
43
|
end
|
45
44
|
|
@@ -59,13 +58,13 @@ class RollupTest < ActiveSupport::TestCase
|
|
59
58
|
(function () {
|
60
59
|
'use strict';
|
61
60
|
|
62
|
-
function cube(x) {
|
61
|
+
function cube ( x ) {
|
63
62
|
return 2 * x * x;
|
64
63
|
}
|
65
64
|
|
66
|
-
console.log(cube(5)); // 125
|
65
|
+
console.log( cube( 5 ) ); // 125
|
67
66
|
|
68
|
-
}()
|
67
|
+
})();
|
69
68
|
FILE
|
70
69
|
end
|
71
70
|
|
@@ -93,13 +92,13 @@ class RollupTest < ActiveSupport::TestCase
|
|
93
92
|
(function () {
|
94
93
|
'use strict';
|
95
94
|
|
96
|
-
function cube(x) {
|
95
|
+
function cube ( x ) {
|
97
96
|
return x * x * x;
|
98
97
|
}
|
99
98
|
|
100
|
-
console.log(cube(5)); // 125
|
99
|
+
console.log( cube( 5 ) ); // 125
|
101
100
|
|
102
|
-
}()
|
101
|
+
})();
|
103
102
|
FILE
|
104
103
|
end
|
105
104
|
|
@@ -126,17 +125,17 @@ class RollupTest < ActiveSupport::TestCase
|
|
126
125
|
(function () {
|
127
126
|
'use strict';
|
128
127
|
|
129
|
-
window.cube = function (x) {
|
128
|
+
window.cube = function ( x ) {
|
130
129
|
return x * x * x;
|
131
130
|
};
|
132
131
|
|
133
|
-
window.square = function (x) {
|
132
|
+
window.square = function ( x ) {
|
134
133
|
return x * x;
|
135
134
|
};
|
136
135
|
|
137
|
-
console.log(square(cube(5)));
|
136
|
+
console.log( square(cube( 5 )) );
|
138
137
|
|
139
|
-
}()
|
138
|
+
})();
|
140
139
|
FILE
|
141
140
|
end
|
142
141
|
|
@@ -168,27 +167,58 @@ class RollupTest < ActiveSupport::TestCase
|
|
168
167
|
(function () {
|
169
168
|
'use strict';
|
170
169
|
|
171
|
-
function cube(x) {
|
170
|
+
function cube ( x ) {
|
172
171
|
return x * x * x;
|
173
172
|
}
|
174
173
|
|
175
|
-
function square(x) {
|
174
|
+
function square ( x ) {
|
176
175
|
return x * x;
|
177
176
|
}
|
178
177
|
|
179
178
|
var maths = [cube, square];
|
180
179
|
|
181
180
|
var x = 1;
|
182
|
-
|
183
181
|
for (var i = 0; i < maths.length; i++) {
|
184
182
|
x = maths[i](x);
|
185
183
|
}
|
186
|
-
|
187
184
|
console.log(x);
|
188
185
|
|
189
|
-
}()
|
186
|
+
})();
|
190
187
|
FILE
|
191
188
|
$d = false
|
192
189
|
end
|
193
190
|
|
191
|
+
test 'import the same file via relative require and full path' do
|
192
|
+
file "#{@npm_path}/module/base.js", <<~JS
|
193
|
+
export default class Base { };
|
194
|
+
JS
|
195
|
+
|
196
|
+
file "#{@npm_path}/module/base/other.js", <<~JS
|
197
|
+
import Base from '../base';
|
198
|
+
|
199
|
+
export default class Lower extends Base { };
|
200
|
+
JS
|
201
|
+
|
202
|
+
file 'main.js', <<~JS
|
203
|
+
import Other from 'module/base/other';
|
204
|
+
import Base from 'module/base';
|
205
|
+
|
206
|
+
console.log( Base, Other );
|
207
|
+
JS
|
208
|
+
|
209
|
+
|
210
|
+
assert_exported_file 'main.js', 'application/javascript', <<~FILE
|
211
|
+
(function () {
|
212
|
+
'use strict';
|
213
|
+
|
214
|
+
class Base { }
|
215
|
+
|
216
|
+
class Lower extends Base { }
|
217
|
+
|
218
|
+
console.log( Base, Lower );
|
219
|
+
|
220
|
+
})();
|
221
|
+
FILE
|
222
|
+
end
|
223
|
+
|
194
224
|
end
|
data/test/resolve_test.rb
CHANGED
@@ -35,6 +35,16 @@ class ResolveTest < ActiveSupport::TestCase
|
|
35
35
|
assert_equal ['test', '*', ['.js'], ['application/javascript']], @env.decompose_path('test/*.js')
|
36
36
|
assert_equal ['test/*', '*', ['.js'], ['application/javascript']], @env.decompose_path('test/*/*.js')
|
37
37
|
assert_equal ['test/**', '*', ['.js'], ['application/javascript']], @env.decompose_path('test/**/*.js')
|
38
|
+
|
39
|
+
assert_equal ['a', 'test', ['.js'], ['application/javascript']], @env.decompose_path('./test.js', 'a/b.js')
|
40
|
+
assert_equal [nil, 'test', ['.js'], ['application/javascript']], @env.decompose_path('./test.js', 'b.js')
|
41
|
+
assert_equal ['a/folder', 'test', ['.js'], ['application/javascript']], @env.decompose_path('./folder/test.js', 'a/b.js')
|
42
|
+
assert_equal ['folder', 'test', ['.js'], ['application/javascript']], @env.decompose_path('./folder/test.js', 'b.js')
|
43
|
+
|
44
|
+
assert_equal [nil, 'test', ['.js'], ['application/javascript']], @env.decompose_path('../test.js', 'a/b.js')
|
45
|
+
assert_equal ["/", 'test', ['.js'], ['application/javascript']], @env.decompose_path('../test.js', '/a/b.js')
|
46
|
+
assert_equal ["folder", 'test', ['.js'], ['application/javascript']], @env.decompose_path('../folder/test.js', 'a/b.js')
|
47
|
+
assert_equal ["/folder", 'test', ['.js'], ['application/javascript']], @env.decompose_path('../folder/test.js', '/a/b.js')
|
38
48
|
end
|
39
49
|
|
40
50
|
test 'resolve' do
|
@@ -83,7 +93,6 @@ class ResolveTest < ActiveSupport::TestCase
|
|
83
93
|
@env.append_path File.join(@path, 'b')
|
84
94
|
@env.append_path File.join(@path, 'a')
|
85
95
|
|
86
|
-
|
87
96
|
assert_exported_file('main.js', 'application/javascript', <<~JS)
|
88
97
|
(function () {
|
89
98
|
'use strict';
|
@@ -94,7 +103,7 @@ class ResolveTest < ActiveSupport::TestCase
|
|
94
103
|
|
95
104
|
console.log( cube( 5 ) ); // 125
|
96
105
|
|
97
|
-
}()
|
106
|
+
})();
|
98
107
|
JS
|
99
108
|
end
|
100
109
|
|
@@ -111,15 +120,15 @@ class ResolveTest < ActiveSupport::TestCase
|
|
111
120
|
end
|
112
121
|
|
113
122
|
test 'resolve a file.*' do
|
114
|
-
file '
|
115
|
-
file '
|
116
|
-
file 'test/
|
123
|
+
file 'foo.js', 'console.log(1);'
|
124
|
+
file 'foo.scss', 'body { background: red; }'
|
125
|
+
file 'test/foo.scss', 'body { background: green; }'
|
117
126
|
|
118
|
-
assert_equal %w(
|
119
|
-
assert_equal %w(
|
127
|
+
assert_equal %w(foo.js foo.scss), @env.resolve('foo.*').map(&:filename)
|
128
|
+
assert_equal %w(foo.css foo.js), @env.resolve('foo.*', accept: ['text/css', 'application/javascript']).map(&:filename)
|
120
129
|
|
121
|
-
assert_equal %w(
|
122
|
-
assert_equal %w(
|
130
|
+
assert_equal %w(foo.js foo.scss test/foo.scss), @env.resolve('**/foo.*').map(&:filename)
|
131
|
+
assert_equal %w(foo.css foo.js test/foo.css), @env.resolve('**/foo.*', accept: ['text/css', 'application/javascript']).map(&:filename)
|
123
132
|
end
|
124
133
|
|
125
134
|
end
|
data/test/server_test.rb
CHANGED
@@ -27,10 +27,10 @@ class ServerTest < ActiveSupport::TestCase
|
|
27
27
|
test "serve single source file" do
|
28
28
|
get "/assets/foo.js"
|
29
29
|
assert_equal 200, last_response.status
|
30
|
-
assert_equal "
|
30
|
+
assert_equal "15", last_response.headers['Content-Length']
|
31
31
|
assert_equal "Accept-Encoding", last_response.headers['Vary']
|
32
32
|
assert_equal <<~JS.strip, last_response.body
|
33
|
-
|
33
|
+
console.log(1);
|
34
34
|
JS
|
35
35
|
end
|
36
36
|
|
@@ -54,7 +54,7 @@ class ServerTest < ActiveSupport::TestCase
|
|
54
54
|
|
55
55
|
get "/assets/main.js"
|
56
56
|
assert_equal <<~JS.strip, last_response.body
|
57
|
-
!function(){
|
57
|
+
!function(){var o;console.log((o=5)*o*o)}();
|
58
58
|
JS
|
59
59
|
end
|
60
60
|
|
@@ -73,7 +73,7 @@ class ServerTest < ActiveSupport::TestCase
|
|
73
73
|
test "serve source with etag headers" do
|
74
74
|
get "/assets/foo.js"
|
75
75
|
|
76
|
-
digest = '
|
76
|
+
digest = '35c146f76e129477c64061bc84511e1090f3d4d8059713e6663dd4b35b1f7642'
|
77
77
|
assert_equal "\"#{digest}\"", last_response.headers['ETag']
|
78
78
|
end
|
79
79
|
|
@@ -107,8 +107,8 @@ class ServerTest < ActiveSupport::TestCase
|
|
107
107
|
'HTTP_IF_NONE_MATCH' => "nope"
|
108
108
|
|
109
109
|
assert_equal 200, last_response.status
|
110
|
-
assert_equal '"
|
111
|
-
assert_equal '
|
110
|
+
assert_equal '"35c146f76e129477c64061bc84511e1090f3d4d8059713e6663dd4b35b1f7642"', last_response.headers['ETag']
|
111
|
+
assert_equal '15', last_response.headers['Content-Length']
|
112
112
|
end
|
113
113
|
|
114
114
|
test "not modified partial response with fingerprint and if-none-match etags match" do
|
@@ -167,8 +167,8 @@ class ServerTest < ActiveSupport::TestCase
|
|
167
167
|
'HTTP_IF_MATCH' => etag
|
168
168
|
|
169
169
|
assert_equal 200, last_response.status
|
170
|
-
assert_equal '"
|
171
|
-
assert_equal '
|
170
|
+
assert_equal '"35c146f76e129477c64061bc84511e1090f3d4d8059713e6663dd4b35b1f7642"', last_response.headers['ETag']
|
171
|
+
assert_equal '15', last_response.headers['Content-Length']
|
172
172
|
end
|
173
173
|
|
174
174
|
test "precondition failed with if-match is a mismatch" do
|
@@ -224,7 +224,12 @@ class ServerTest < ActiveSupport::TestCase
|
|
224
224
|
assert_equal "pass", last_response.headers['X-Cascade']
|
225
225
|
end
|
226
226
|
|
227
|
-
test "re-throw JS exceptions in the browser" do
|
227
|
+
test "re-throw JS exceptions in the browser when using babel" do
|
228
|
+
@env.unregister_preprocessor('application/javascript', Condenser::JSAnalyzer)
|
229
|
+
@env.register_preprocessor 'application/javascript', Condenser::BabelProcessor.new(@path,
|
230
|
+
presets: [ ['@babel/preset-env', { modules: false, targets: { browsers: 'firefox > 41' } }] ]
|
231
|
+
)
|
232
|
+
|
228
233
|
file 'error.js', "var error = {;"
|
229
234
|
|
230
235
|
get "/assets/error.js"
|
@@ -248,7 +253,7 @@ class ServerTest < ActiveSupport::TestCase
|
|
248
253
|
JS
|
249
254
|
get "/assets/%E6%97%A5%E6%9C%AC%E8%AA%9E.js"
|
250
255
|
assert_equal <<~JS.strip, last_response.body
|
251
|
-
|
256
|
+
console.log("日本語");
|
252
257
|
JS
|
253
258
|
end
|
254
259
|
|
data/test/templates/ejs_test.rb
CHANGED
@@ -4,7 +4,6 @@ class CondenserEJSTest < 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
|
|
@@ -15,14 +14,10 @@ class CondenserEJSTest < ActiveSupport::TestCase
|
|
15
14
|
import { escape } from 'ejs';
|
16
15
|
export default function (locals) {
|
17
16
|
var __output = [],
|
18
|
-
|
19
|
-
|
17
|
+
__append = __output.push.bind(__output);
|
20
18
|
__append("1");
|
21
|
-
|
22
19
|
__append(escape(1 + 1));
|
23
|
-
|
24
20
|
__append("3\\n");
|
25
|
-
|
26
21
|
return __output.join("");
|
27
22
|
}
|
28
23
|
JS
|
@@ -35,14 +30,10 @@ class CondenserEJSTest < ActiveSupport::TestCase
|
|
35
30
|
import { escape } from 'ejs';
|
36
31
|
export default function (locals) {
|
37
32
|
var __output = [],
|
38
|
-
|
39
|
-
|
33
|
+
__append = __output.push.bind(__output);
|
40
34
|
__append("1");
|
41
|
-
|
42
35
|
__append(escape(locals.input));
|
43
|
-
|
44
36
|
__append("3\\n");
|
45
|
-
|
46
37
|
return __output.join("");
|
47
38
|
}
|
48
39
|
JS
|
data/test/templates/erb_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -39,6 +39,7 @@ class ActiveSupport::TestCase
|
|
39
39
|
@env.unregister_writer(Condenser::BrotliWriter)
|
40
40
|
@env.context_class.class_eval do
|
41
41
|
def asset_path(path, options = {})
|
42
|
+
path = environment.find!(path, options).path
|
42
43
|
"/assets/#{path}"
|
43
44
|
end
|
44
45
|
end
|
@@ -52,9 +53,10 @@ class ActiveSupport::TestCase
|
|
52
53
|
assert_equal json, jbuild(&block)
|
53
54
|
end
|
54
55
|
|
55
|
-
def file(name, source)
|
56
|
-
|
57
|
-
|
56
|
+
def file(name, source, base: nil)
|
57
|
+
base ||= @path
|
58
|
+
dir = name.include?('/') ? File.join(base, File.dirname(name)) : base
|
59
|
+
path = File.join(base, name)
|
58
60
|
|
59
61
|
FileUtils.mkdir_p(dir)
|
60
62
|
if File.exist?(path)
|
@@ -62,6 +64,7 @@ class ActiveSupport::TestCase
|
|
62
64
|
sleep(1 - stat) if stat < 1
|
63
65
|
end
|
64
66
|
File.write(path, source)
|
67
|
+
sleep 0.25 if @env.build_cache.listening
|
65
68
|
end
|
66
69
|
|
67
70
|
def rm(name)
|
@@ -76,6 +79,7 @@ class ActiveSupport::TestCase
|
|
76
79
|
assert_equal path.delete_prefix('/'), asset.filename
|
77
80
|
assert_equal Array(mime_types), asset.content_types
|
78
81
|
assert_equal(source.rstrip, asset.source.rstrip) if !source.nil?
|
82
|
+
asset
|
79
83
|
end
|
80
84
|
|
81
85
|
def assert_exported_file(path, mime_types, source=nil)
|
@@ -86,6 +90,7 @@ class ActiveSupport::TestCase
|
|
86
90
|
assert_equal path, asset.filename
|
87
91
|
assert_equal Array(mime_types), asset.content_types
|
88
92
|
assert_equal(source.rstrip, asset.source.rstrip) if !source.nil?
|
93
|
+
asset
|
89
94
|
end
|
90
95
|
|
91
96
|
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CondenserDartSCSSTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
@env.clear_pipeline
|
8
|
+
@env.register_transformer 'text/scss', 'text/css', Condenser::DartScssTransformer
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'find' do
|
12
|
+
file 'test.scss', <<~SCSS
|
13
|
+
body {
|
14
|
+
background-color: green;
|
15
|
+
|
16
|
+
&:hover {
|
17
|
+
background-color: blue;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
SCSS
|
21
|
+
|
22
|
+
assert_file 'test.css', 'text/css', <<~CSS
|
23
|
+
body {
|
24
|
+
background-color: green;
|
25
|
+
}
|
26
|
+
body:hover {
|
27
|
+
background-color: blue;
|
28
|
+
}
|
29
|
+
CSS
|
30
|
+
end
|
31
|
+
|
32
|
+
test 'scss import globing' do
|
33
|
+
file "c/dir/a.scss", "body { color: blue; }"
|
34
|
+
file "c/dir/b.scss", "body { color: green; }"
|
35
|
+
|
36
|
+
file 'c/test.scss', '@import "./dir/*"'
|
37
|
+
|
38
|
+
assert_file 'c/test.css', 'text/css', <<~CSS
|
39
|
+
body {
|
40
|
+
color: blue;
|
41
|
+
}
|
42
|
+
|
43
|
+
body {
|
44
|
+
color: green;
|
45
|
+
}
|
46
|
+
CSS
|
47
|
+
|
48
|
+
file 'c/test2.scss', '@import "c/dir/*"'
|
49
|
+
|
50
|
+
assert_file 'c/test2.css', 'text/css', <<~CSS
|
51
|
+
body {
|
52
|
+
color: blue;
|
53
|
+
}
|
54
|
+
|
55
|
+
body {
|
56
|
+
color: green;
|
57
|
+
}
|
58
|
+
CSS
|
59
|
+
end
|
60
|
+
|
61
|
+
test "url functions" do
|
62
|
+
file 'a.scss', <<~SCSS
|
63
|
+
body {
|
64
|
+
color: green; }
|
65
|
+
SCSS
|
66
|
+
|
67
|
+
file 'test.scss', <<~SCSS
|
68
|
+
@import 'a';
|
69
|
+
|
70
|
+
div {
|
71
|
+
url: asset-url("foo.svg");
|
72
|
+
url: image-url("foo.png");
|
73
|
+
url: video-url("foo.mov");
|
74
|
+
url: audio-url("foo.mp3");
|
75
|
+
url: font-url("foo.woff2");
|
76
|
+
url: font-url("foo.woff");
|
77
|
+
url: javascript-url("foo.js");
|
78
|
+
url: stylesheet-url("foo.css");
|
79
|
+
}
|
80
|
+
SCSS
|
81
|
+
|
82
|
+
file 'foo.svg', ''
|
83
|
+
file 'foo.png', ''
|
84
|
+
file 'foo.mov', ''
|
85
|
+
file 'foo.mp3', ''
|
86
|
+
file 'foo.woff2', ''
|
87
|
+
file 'foo.woff', ''
|
88
|
+
file 'foo.js', ''
|
89
|
+
file 'foo.css', ''
|
90
|
+
|
91
|
+
assert_file 'test.css', 'text/css', <<~CSS
|
92
|
+
body {
|
93
|
+
color: green;
|
94
|
+
}
|
95
|
+
|
96
|
+
div {
|
97
|
+
url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.svg);
|
98
|
+
url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.png);
|
99
|
+
url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.mov);
|
100
|
+
url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.mp3);
|
101
|
+
url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.woff2);
|
102
|
+
url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.woff);
|
103
|
+
url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js);
|
104
|
+
url: url(/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css);
|
105
|
+
}
|
106
|
+
CSS
|
107
|
+
|
108
|
+
asset = @env.find('test.css')
|
109
|
+
assert_equal ["a.scss", "foo.svg", "foo.png", "foo.mov", "foo.mp3", "foo.woff2", "foo.woff", "foo.js", "foo.css"], asset.process_dependencies.map(&:filename)
|
110
|
+
assert_equal ["a.scss", "foo.svg", "foo.png", "foo.mov", "foo.mp3", "foo.woff2", "foo.woff", "foo.js", "foo.css"], asset.export_dependencies.map(&:filename)
|
111
|
+
end
|
112
|
+
|
113
|
+
test "sass dependencies" do
|
114
|
+
file 'd.scss', <<~SCSS
|
115
|
+
$secondary-color: #444;
|
116
|
+
SCSS
|
117
|
+
|
118
|
+
file 'a.scss', <<~SCSS
|
119
|
+
@import 'd';
|
120
|
+
$primary-color: #333;
|
121
|
+
SCSS
|
122
|
+
|
123
|
+
file 'b.scss', <<~SCSS
|
124
|
+
body {
|
125
|
+
color: $primary-color;
|
126
|
+
}
|
127
|
+
SCSS
|
128
|
+
|
129
|
+
file 'c.scss', <<~SCSS
|
130
|
+
@import 'a';
|
131
|
+
@import 'b';
|
132
|
+
SCSS
|
133
|
+
|
134
|
+
asset = @env.find('c.css')
|
135
|
+
assert_equal ["a.scss", "d.scss", "b.scss"], asset.process_dependencies.map(&:filename)
|
136
|
+
assert_equal ["a.scss", "d.scss", "b.scss"], asset.export_dependencies.map(&:filename)
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|