coffee-assets
Sprockets syntax for aggregating/minifying/gzipping CoffeeTemplates, CoffeeStylesheets, and CoffeeSprites.
Last updated 7 years ago by mikesmullin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install coffee-assets 
SYNC missed versions from official npm registry.

Why CoffeeAssets?

CoffeeAssets will bulk compile CoffeeTemplates, CoffeeScript, and CoffeeStylesheets with support for CoffeeSprites. Optionally aggregating these using Sprockets-like #= require ./../file directives, minifying with Google Closure, suffixing a digest, writing a manifest.json, and gzipping into the neat little production-quality packages you expect. Additionally, its incredibly fast, with no meddling middleware dependencies, or slow transpilers inbetween.

Inspired by mincer, coffee-sprites, and buildr.npm.

Quick Examples

# CoffeeScripts
watch [
    in: 'precompile'
    suffix: '/server.js.coffee'
    out: ''
  ,
    in: 'precompile/controllers/server'
    out: 'static/app/controllers'
  ,
    in: 'precompile/controllers/shared'
    out:  'static/public/assets/controllers'
  ,
    in: 'precompile/models/server'
    out: 'static/app/models'
  ,
    in: 'precompile/models/shared'
    out: 'static/public/assets/models'
  ,
    in: [
      'precompile/assets/behaviors'
      'precompile/vendor/assets'
    ]
    out: 'static/public/assets'
], '/**/*.{js,js.coffee}', (infile, outfile) ->
  assets.precompile infile, assets.compiler(), (err, compiled) ->
    return notify 'Cake CoffeeAssets CoffeeScript compiler', err, true, true if err
    write outfile.replace(/\.coffee$/,''), compiled

# CoffeeStylesheets
watch [
  in: [
    'precompile/assets/stylesheets'
    'precompile/vendor/assets'
  ],
  out: 'static/public/assets'
# filenames with underscore prefix are only compiled via require
], '/**/!(@(_))*.{css,css.coffee}', (infile, outfile) ->
  assets.precompile infile, assets.compiler(
    stylesheet_options:
      format: true
    sprite_options:
      image_path: 'precompile/assets/sprites/'
      sprite_path: 'static/public/assets/'
      sprite_url: '/assets/'
  ), (err, compiled) ->
    return notify 'Cake CoffeeAssets CoffeeStylesheets compiler', err, true, true if err
    write outfile.replace(/\.coffee/,''), compiled

# CoffeeTemplates (server-side; single function per file)
watch [
  in: 'precompile/views/server'
  out: 'static/app/views'
], '/**/*.html.coffee', (infile, outfile) ->
  assets.precompile infile, assets.compiler(
    template_options:
      format: true
  ), (err, compiled) ->
    return notify 'Cake CoffeeAssets CoffeeTemplates compiler', err, true, true if err
    write outfile.replace(/\.html.coffee/,'.js'), compiled

# CoffeeTemplates (client-side; multi-function aggregated to single file)
watch 'precompile/views/shared/**/*.html.coffee', ->
  # if ANY template file changes, ALL must be recompiled
  # because they are aggregated into a single templates.js file and function()
  assets.precompile_templates 'precompile/views/shared', {
    template_options:
      format: true
  }, (err, compiled) ->
    return notify 'Cake CoffeeAssets CoffeeTemplates compiler', err, true, true if err
    write 'static/public/assets/templates.js', compiled

For the most recent and comprehensive examples, see CoffeeShop's Cakefile.

Current Tags

  • 0.1.5                                ...           latest (7 years ago)

7 Versions

  • 0.1.5                                ...           7 years ago
  • 0.1.4                                ...           7 years ago
  • 0.1.3                                ...           7 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |