Sha256: ff3f235029a7e3bb69992b750a9e4f0c4470b3fc3bef6b81d7ec9dc0ec73c8d9

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true
require 'sewing_kit/webpack/manifest/base'

module SewingKit
  module Webpack
    class Manifest
      class Development < Base
        def initialize
          super
          @metadata_path = nil
        end

        def clear_cache!
          super
          @metadata_path = nil
        end

        def metadata
          load_metadata
        end

        def load_metadata
          begin
            return load_metadata_from_fs(@metadata_path) if @metadata_path
          rescue => e
            Rails.logger.warn "[sewing_kit] could not read manifest from #{@metadata_path}; falling back to node.  #{e}"
            @metadata_path = nil
          end

          result = load_metadata_from_node
          raise LegacyManifestError, result unless result['entrypoints'] || result['development']

          @metadata_path = result && result['path']
          result
        end

        def load_metadata_from_fs(path)
          begin
            json_str = File.read(path)
          rescue => e
            raise ManifestLoadError.new(path, e)
          end

          begin
            JSON.parse(json_str)
          rescue => e
            raise ManifestParseError, e
          end
        end

        protected

        def mode
          'development'
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sewing_kit-0.31.0 lib/sewing_kit/webpack/manifest/development.rb
sewing_kit-0.30.0 lib/sewing_kit/webpack/manifest/development.rb
sewing_kit-0.29.2 lib/sewing_kit/webpack/manifest/development.rb
sewing_kit-0.29.1 lib/sewing_kit/webpack/manifest/development.rb