Class: Condenser

Inherits:
Object
  • Object
show all
Includes:
Environment, Pipeline, Resolve
Defined in:
lib/condenser/errors.rb,
lib/condenser.rb,
lib/condenser/asset.rb,
lib/condenser/utils.rb,
lib/condenser/export.rb,
lib/condenser/server.rb,
lib/condenser/context.rb,
lib/condenser/resolve.rb,
lib/condenser/version.rb,
lib/condenser/manifest.rb,
lib/condenser/pipeline.rb,
lib/condenser/build_cache.rb,
lib/condenser/environment.rb,
lib/condenser/encoding_utils.rb,
lib/condenser/processors/node_processor.rb

Overview

Basic Condenser error classes

Defined Under Namespace

Modules: EncodingUtils, Environment, ParseHelpers, Pipeline, Resolve, Sass, Utils Classes: Asset, BabelProcessor, BrotliWriter, BuildCache, CSSMediaCombinerProcessor, Cache, CacheStore, CommandNotFoundError, ContentTypeMismatch, Context, DartSassTransformer, DartScssTransformer, EjsTemplate, Error, Erubi, Export, FileNotFound, FileWriter, JSAnalyzer, JstTransformer, Manifest, NodeProcessor, NotFound, PurgeCSSProcessor, RollupProcessor, SVGTransformer, SassMinifier, SassTransformer, ScssTransformer, Server, SyntaxError, TerserMinifier, UglifyMinifier, ZlibWriter

Constant Summary collapse

VERSION =
'1.4'

Constants included from Pipeline

Pipeline::CONFIG_VARS

Instance Attribute Summary collapse

Attributes included from Environment

#cache, #context_class, #npm_path, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resolve

#[], #build, #build_cache, #decompose_path, #expand_path, #find, #find!, #find_export, #has_dir?, #match_mime_type?, #match_mime_types?, #mime_type_match_accept?, #resolve, #resolve!, #reverse_mapping, #writers_for_mime_type

Methods included from Pipeline

#clear_pipeline, #minifier_for, #pipline_digest, #pipline_hash, #pipline_to_json, prepended, #register_exporter, #register_mime_type, #register_minifier, #register_postprocessor, #register_preprocessor, #register_template, #register_transformer, #register_writer, #unregister_exporter, #unregister_minifier, #unregister_preprocessor, #unregister_writer

Methods included from Environment

#append_npm_path, #append_path, #clear_path, #load_processors, #new_context_class, #prepend_path

Constructor Details

#initialize(*path, logger: nil, digestor: nil, cache: nil, pipeline: nil, npm_path: nil, base: nil, &block) ⇒ Condenser

base: If base is passed assets cache_keys will be realitve to this.

This allows deploy systems like Capistrano to take advantage of the
cache even though it precompiles assets in a different folder


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/condenser.rb', line 51

def initialize(*path, logger: nil, digestor: nil, cache: nil, pipeline: nil, npm_path: nil, base: nil, &block)
  @logger = logger || Logger.new($stdout, level: :info)
  @path = []
  append_path(path)
  self.npm_path = npm_path
  @base = base
  @cache = cache || Cache::MemoryStore.new
  @build_cc = 0
  self.digestor = digestor || Digest::SHA256

  if block
    configure(&block)
  elsif pipeline != false
    self.configure do
      register_preprocessor 'application/javascript', Condenser::JSAnalyzer
      # register_preprocessor 'application/javascript', Condenser::BabelProcessor
      register_exporter     'application/javascript', Condenser::RollupProcessor
      register_minifier     'application/javascript', Condenser::UglifyMinifier
      
      register_minifier  'text/css', Condenser::SassMinifier
    
      register_writer Condenser::FileWriter.new
      register_writer Condenser::ZlibWriter.new
      if Gem::Specification::find_all_by_name('brotli').any?
        register_writer Condenser::BrotliWriter.new
      end
    end
  end
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



46
47
48
# File 'lib/condenser.rb', line 46

def base
  @base
end

#digestorObject

Returns the value of attribute digestor.



46
47
48
# File 'lib/condenser.rb', line 46

def digestor
  @digestor
end

#loggerObject

Returns the value of attribute logger.



46
47
48
# File 'lib/condenser.rb', line 46

def logger
  @logger
end

Class Method Details

.configure(&block) ⇒ Object



42
43
44
# File 'lib/condenser.rb', line 42

def self.configure(&block)
  instance_eval(&block)
end

Instance Method Details

#configure(&block) ⇒ Object



81
82
83
# File 'lib/condenser.rb', line 81

def configure(&block)
  instance_eval(&block)
end