0.0
No commit activity in last 3 years
No release in over 3 years
Simple tool to automatically unify and minify javascript and css website assets
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

Unified Assets (v0.0.1)

A small utility for unifying (and minifying) static javascript and css asset files, either at build time or at run-time.

You declare a list of source files, and the gem will unify and minify them.

The gem also provides a simple rack-based web server that will serve up your static website files and automatically recreate the unified files if the underlying source files have been modified.

NOTE:

This gem is really for my own personal use when building some of my HTML-only games. They consist of pure client-side html, javascript and css, with no dynamic server back end, but I still want to auto-generate unified and minified scripts and styles.

You will almost certainly be better off with more robust tools such as:

  • sprockets - if you have a ruby/rails back end
  • gears - if you have a python back end
  • mincer - if you have a node back end
  • requirejs - if you want to do it the AMD way

This is just a tiny little gem that works well for my specific purposes and might not be the best tool for others. Use your own judgement.

Installation

$ gem install unified-assets

Usage

To generate a unified/minified scripts.js and styles.css add tasks to your Rakefile

require 'unified_assets/tasks'

UnifiedAssets::Tasks.new do |t|
  t.minify = true
  t.assets = {

    "scripts.js"  => [
      'js/game/vendor/stats.js',            # https://github.com/mrdoob/stats.js
      'js/game/vendor/sizzle.js',           # http://sizzlejs.com/
      'js/game/vendor/animator.js',         # http://berniesumption.com/software/animator/
      'js/game/vendor/audio-fx.js',         # https://github.com/jakesgordon/javascript-audio-fx
      'js/game/vendor/state-machine.js',    # https://github.com/jakesgordon/javascript-state-machine
      'js/game/base.js',
      'js/game/game.js',
      'js/game/dom.js',
      'js/game/menu.js',
      'js/game/key.js',
      'js/game/math.js',
      'js/game/vector.js',
      'js/snakes.js'
    ],

    "styles.css" => [
      'css/vendor/normalize.css',
      'css/snakes.css'
    ]

  }
end

Will make 3 rake tasks available to you:

> rake -T

rake assets:clear     # clear unified asset files
rake assets:create    # create unified asset files
rake assets:server    # simple webserver that auto-regenerates assets if they are out of date

Use rake assets:create whenever your source files have changed to recreate the unified/minified versions.

Use rake assets:server to run a simple rack-based web server that can serve up your static website and will automatically regenerate your unified assets if the source files have been changed.

TODO

  • command line scripts
  • support templating (e.g. sass, coffeescript, erb)

License

MIT license.

Contact

If you have any ideas, feedback, requests or bug reports, you can reach me at jake@codeincomplete.com, or via my website: Code inComplete.