Module: Gotenberg::Helpers::ViteHelpers

Defined in:
lib/gotenberg/helpers/vite_helpers.rb

Instance Method Summary collapse

Instance Method Details

#gotenberg_vite_image_tag(source) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/gotenberg/helpers/vite_helpers.rb', line 4

def gotenberg_vite_image_tag source
  ensure_vite_ruby!

  path = gotenberg_vite_manifest.path_for(source)

  gotenberg_context_tag(
    tag: 'image',
    src: gotenberg_vite_source_location(path)
  )
end

#gotenberg_vite_javascript_tag(source) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gotenberg/helpers/vite_helpers.rb', line 28

def gotenberg_vite_javascript_tag source
  ensure_vite_ruby!

  entries = gotenberg_vite_manifest.resolve_entries(
    source,
    type: :javascript
  )

  tags = entries[:imports].map do |path|
    gotenberg_modulepreload_tag(path)
  end

  tags.concat(
    entries[:scripts].map do |path|
      gotenberg_modulejs_tag(path)
    end
  )

  safe_join(tags)
end

#gotenberg_vite_stylesheet_tag(source) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gotenberg/helpers/vite_helpers.rb', line 15

def gotenberg_vite_stylesheet_tag source
  ensure_vite_ruby!

  path = gotenberg_vite_manifest.path_for(source, type: :stylesheet)

  gotenberg_context_tag(
    tag: 'css',
    src: gotenberg_vite_source_location(path),
    base_path: gotenberg_vite_stylesheet_base_path,
    skip_analyze: false
  )
end