joecorcoran / Pannier / Docs
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
Scenario: Assets are concatenated
- Given the file "
input/a.js" containsjavascript/* one */ - And the file "
input/b.js" containsjavascript/* two */ - And the file "
.assets.rb" containsrubyinput '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 containjavascript/* one */ /* two */
Scenario: Assets concatenated by user concatenator
- Given the file "
input/a.js" containsjavascriptvar a = 1; - And the file "
input/b.js" containsjavascriptvar b = 2; - And a loaded ruby file contains
ruby
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" containsrubyinput '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 containjavascript/* Made by Computer Corp. LLC */ var a = 1;var b = 2;
Source: features/asset_concatenation.feature at commit 97ce086f, Pannier (MIT license).