Sha256: 559570163d08320f28f15aacc7f238c409537f164f8384a2282906dd671658bc

Contents?: true

Size: 957 Bytes

Versions: 1

Compression:

Stored size: 957 Bytes

Contents

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

class WebpackerHelpers::Env < WebpackerHelpers::FileLoader
  class << self
    def current
      raise WebpackerHelpers::FileLoader::FileLoaderError.new("WebpackerHelpers::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_helpers.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

1 entries across 1 versions & 1 rubygems

Version Path
webpacker_helpers-3.0.0.beta.1 lib/webpacker_helpers/env.rb