Class: Charsi::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/charsi/asset.rb

Overview

Itterates each assets, processes them, and copies them to the output directory.

Constant Summary collapse

UNPKG_BASE =
'https://unpkg.com/'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Asset

Returns a new instance of Asset.



6
7
8
# File 'lib/charsi/asset.rb', line 6

def initialize(config)
  @config = config
end

Instance Method Details

#build ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/charsi/asset.rb', line 10

def build
  build_vendor

  assets_path = @config.path(:assets_dir, '**', '*.*')

  Dir.glob(assets_path).each do |asset|
    destination_dir  = @config.path(:output_dir, 'assets')
    destination_path = asset.sub(@config.path(:assets_dir), destination_dir)

    next process_tailwind(asset, destination_path) if asset.include?('tailwind.css')

    Charsi::FileManagement.copy(asset, destination_path)
  end
end