Class: FrontEndTasks::Documents::JsDocument
Instance Attribute Summary
Attributes inherited from BaseDocument
#compiled_path
Instance Method Summary
collapse
#initialize
Instance Method Details
#compile ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/front_end_tasks/documents/js_document.rb', line 8
def compile
path_content_pairs = {}
workers = find_worker_references(@public_root, @content)
workers.each do |worker|
new_files = worker.compile
path_content_pairs.merge!(new_files)
end
@content = replace_worker_import_scripts(@public_root, @content)
compiled_content = Uglifier.compile(@content)
path_content_pairs.merge!({
@compiled_path => compiled_content
})
path_content_pairs
end
|
#included_scripts(public_root = nil) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/front_end_tasks/documents/js_document.rb', line 27
def included_scripts(public_root = nil)
paths = []
import_scripts = @content.scan(/importScripts\(([^)]+)\)/)
import_scripts.each do |import_script|
argument_content = import_script[0]
paths = argument_content.split(",").map { |p| p.strip.chop.reverse.chop.reverse }
end
paths.map do |path|
if public_root
File.expand_path(File.join(public_root, path))
else
path
end
end
end
|