Sha256: 1709ca20dc940f34e41d190f9bf0bdcc47e948a50efeae31faa875ef43df30a2

Contents?: true

Size: 936 Bytes

Versions: 3

Compression:

Stored size: 936 Bytes

Contents

# Singleton registry for determining NODE_ENV from config/webpacker_lite.yml
require "webpacker_lite/file_loader"

class WebpackerLite::Env < WebpackerLite::FileLoader
  class << self
    def current
      raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Env.load must be called first") unless instance
      instance.data
    end

    def hot_loading?
      (ENV["HOT_RELOADING"].present? && (
      ENV["HOT_RELOADING"].upcase == "YES" ||
        ENV["HOT_RELOADING"].upcase == "TRUE")) ||
        current["hot_reloading_enabled_by_default"]
    end

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

  private
    def load_data
      environments = File.exist?(@path) ? YAML.load(File.read(@path)).keys : [].freeze
      return ENV["NODE_ENV"] if environments.include?(ENV["NODE_ENV"])
      return Rails.env if environments.include?(Rails.env)
      "production"
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webpacker_lite-2.1.0 lib/webpacker_lite/env.rb
webpacker_lite-2.0.4 lib/webpacker_lite/env.rb
webpacker_lite-2.0.3 lib/webpacker_lite/env.rb