Sha256: 60c786b736ccaf4f9deded7060fdefbe18986f6f1e937d747ef01099ed67f888

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

# Loads webpacker configuration from config/webpack/paths.yml
require "webpacker_lite/file_loader"
require "webpacker_lite/env"

class WebpackerLite::Configuration < WebpackerLite::FileLoader
  class << self
    def config_path
      Rails.root.join(paths.fetch(:config, "config/webpack"))
    end

    def file_path
      Rails.root.join("config", "webpack", "paths.yml")
    end

    def manifest_path
      Rails.root.join(output_path, paths.fetch(:manifest, "manifest.json"))
    end

    def output_path
      Rails.root.join(paths.fetch(:output, "public"), paths.fetch(:assets, "assets/webpack"))
    end

    def paths
      load if WebpackerLite::Env.development?
      raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Configuration.load must be called first") unless instance
      instance.data
    end

    def source_path
      Rails.root.join(paths.fetch(:source, "app/javascript"))
    end
  end

  private
    def load
      return super unless File.exist?(@path)
      HashWithIndifferentAccess.new(YAML.load(File.read(@path))[WebpackerLite::Env.current])
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
webpacker_lite-1.0.0 lib/webpacker_lite/configuration.rb
webpacker_lite-0.0.5 lib/webpacker_lite/configuration.rb
webpacker_lite-0.0.4 lib/webpacker_lite/configuration.rb
webpacker_lite-0.0.3 lib/webpacker_lite/configuration.rb