Sha256: a5483330b5f79ede7f952544e7959ad1b79a97d35aa999ca165a22d28223e0d8

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

require "pakyow/assets/asset"

module Pakyow
  class Application
    module Behavior
      # Registers assets from the app's frontend/assets directory.
      #
      module Assets
        extend Support::Extension

        apply_extension do
          after "load", "load.assets" do
            config.assets.paths.each do |assets_path|
              Dir.glob(File.join(assets_path, "**/*")) do |path|
                next if config.assets.packs.paths.any? { |packs_path|
                  path.start_with?(packs_path)
                } || File.basename(path).start_with?("_")

                if config.assets.extensions.include?(File.extname(path))
                  prefix = if is_a?(Plugin)
                    self.class.mount_path
                  else
                    "/"
                  end

                  self.class.asset << Pakyow::Assets::Asset.new_from_path(
                    path,
                    config: config.assets,
                    source_location: assets_path,
                    prefix: prefix,
                    related: state(:asset)
                  )
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pakyow-assets-1.0.6 lib/pakyow/application/behavior/assets.rb
pakyow-assets-1.0.5 lib/pakyow/application/behavior/assets.rb
pakyow-assets-1.0.4 lib/pakyow/application/behavior/assets.rb
pakyow-assets-1.0.3 lib/pakyow/application/behavior/assets.rb
pakyow-assets-1.0.2 lib/pakyow/application/behavior/assets.rb
pakyow-assets-1.0.1 lib/pakyow/application/behavior/assets.rb
pakyow-assets-1.0.0 lib/pakyow/application/behavior/assets.rb