Class: BunBunBundle::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/bun_bun_bundle/config.rb

Defined Under Namespace

Classes: DevServer, EntryPoints

Constant Summary collapse

CONFIG_PATH =
'config/bun.json'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Config

Returns a new instance of Config.



12
13
14
15
16
17
18
19
# File 'lib/bun_bun_bundle/config.rb', line 12

def initialize(data = {})
  @manifest_path = data.fetch('manifestPath', 'public/bun-manifest.json')
  @out_dir = data.fetch('outDir', 'public/assets')
  @public_path = data.fetch('publicPath', '/assets')
  @static_dirs = data.fetch('staticDirs', %w[app/assets/images app/assets/fonts])
  @entry_points = EntryPoints.new(data.fetch('entryPoints', {}))
  @dev_server = DevServer.new(data.fetch('devServer', {}))
end

Instance Attribute Details

#dev_serverObject (readonly)

Returns the value of attribute dev_server.



9
10
11
# File 'lib/bun_bun_bundle/config.rb', line 9

def dev_server
  @dev_server
end

#entry_pointsObject (readonly)

Returns the value of attribute entry_points.



9
10
11
# File 'lib/bun_bun_bundle/config.rb', line 9

def entry_points
  @entry_points
end

#manifest_pathObject (readonly)

Returns the value of attribute manifest_path.



9
10
11
# File 'lib/bun_bun_bundle/config.rb', line 9

def manifest_path
  @manifest_path
end

#out_dirObject (readonly)

Returns the value of attribute out_dir.



9
10
11
# File 'lib/bun_bun_bundle/config.rb', line 9

def out_dir
  @out_dir
end

#public_pathObject (readonly)

Returns the value of attribute public_path.



9
10
11
# File 'lib/bun_bun_bundle/config.rb', line 9

def public_path
  @public_path
end

#static_dirsObject (readonly)

Returns the value of attribute static_dirs.



9
10
11
# File 'lib/bun_bun_bundle/config.rb', line 9

def static_dirs
  @static_dirs
end

Class Method Details

.load(root: Dir.pwd) ⇒ Object



21
22
23
24
25
# File 'lib/bun_bun_bundle/config.rb', line 21

def self.load(root: Dir.pwd)
  path = File.join(root, CONFIG_PATH)
  data = File.exist?(path) ? JSON.parse(File.read(path)) : {}
  new(data)
end