Logo: Relish

  1. Sign in

Project: Pannier v0.4.0

Asset concatenation

In order that my assets are delivered by as few requests as possible
As a developer
I want to concatenate multiple assets into one file

Scenarios
Assets are concatenated
Given
the file "input/a.js" contains
/* one */
And
the file "input/b.js" contains
/* two */
And
the file ".assets.rb" contains
input  'input'
output 'output'

package :main do
  assets '*.js'
  concat 'main.js'
end
When
the app is loaded
And
the app has been processed
Then
the file "output/main.js" should contain
/* one */
/* two */
Assets concatenated by user concatenator
Given
the file "input/a.js" contains
var a = 1;
And
the file "input/b.js" contains
var b = 2;
And
a loaded ruby file contains
class ConcatWithBanner
  def initialize(message)
    @message = message
  end
  def call(content_array)
    content = "/* #{@message} */\n"
    content << content_array.join
    content
  end
end
And
the file ".assets.rb" contains
input  'input'
output 'output'

package :main do
  assets '*.js'
  concat 'main.js', ConcatWithBanner.new('Made by Computer Corp. LLC')
end
When
the app is loaded
And
the app has been processed
Then
the file "output/main.js" should contain
/* Made by Computer Corp. LLC */
var a = 1;var b = 2;

Last published about 4 years ago by joecorcoran.