Sha256: c35b8eb16af5208070d7fe6ae7b8e9c9e71abbbe392f972b114f560ac3313c4b

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require "pakyow/support/extension"

require "pakyow/assets/asset"

module Pakyow
  module Assets
    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 << 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

5 entries across 5 versions & 1 rubygems

Version Path
pakyow-assets-1.0.0.rc5 lib/pakyow/assets/behavior/assets.rb
pakyow-assets-1.0.0.rc4 lib/pakyow/assets/behavior/assets.rb
pakyow-assets-1.0.0.rc3 lib/pakyow/assets/behavior/assets.rb
pakyow-assets-1.0.0.rc2 lib/pakyow/assets/behavior/assets.rb
pakyow-assets-1.0.0.rc1 lib/pakyow/assets/behavior/assets.rb