Sha256: 67b857df6bd4b266cd6ec9292f102939a4f8b5edb92eaee1172beee59b4b75fb

Contents?: true

Size: 887 Bytes

Versions: 5

Compression:

Stored size: 887 Bytes

Contents

# frozen_string_literal: true

module EasyML
  module ApplicationHelper
    # Override: Returns the engine assets manifest.
    def easy_ml_manifest
      ViteRuby.new(root: EasyML::Engine.root).manifest
    end

    def prod_script_tags
      vite_manifest = Thread.current[:vite_manifest] ||= JSON.parse(File.read(EasyML::Engine.root.join("public/easy_ml/assets/.vite/manifest.json")))
      entrypoint = vite_manifest.dig("entrypoints/Application.tsx")
      application_js = entrypoint.dig("file")
      css_files = entrypoint.dig("css")

      # Create HTML tags for the JavaScript and CSS using Rails tag helpers
      tags = []
      tags << javascript_include_tag("/easy_ml/assets/#{application_js}", type: "module")
      css_files.each do |css_file|
        tags << stylesheet_link_tag("/easy_ml/assets/#{css_file}")
      end
      tags.join("\n").html_safe
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
easy_ml-0.2.0.pre.rc45 app/helpers/easy_ml/application_helper.rb
easy_ml-0.2.0.pre.rc44 app/helpers/easy_ml/application_helper.rb
easy_ml-0.2.0.pre.rc43 app/helpers/easy_ml/application_helper.rb
easy_ml-0.2.0.pre.rc41 app/helpers/easy_ml/application_helper.rb
easy_ml-0.2.0.pre.rc40 app/helpers/easy_ml/application_helper.rb