Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

support for Sprockets using Snockets #8

Open
wants to merge 3 commits into from

1 participant

Prabir Shrestha
Prabir Shrestha

rather then using the javascript settings. Snockets allows us to use javascript comments to include dependency

//= require console.log
//= require _libs/json2
//= require _libs/jquery-1.7.2
//= require _libs/underscore
//= require _libs/backbone
//= require app
//= require_tree models/
//= require_tree collections/
//= require_tree routers/

Takes dependency on snockets. https://github.com/TrevorBurnham/snockets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 3 changed files with 19 additions and 0 deletions. Show diff stats Hide diff stats

  1. +7 0 README.md
  2. +11 0 lib/handlers.js
  3. +1 0  package.json
7 README.md
Source Rendered
@@ -35,6 +35,11 @@ Via [npm](http://github.com/isaacs/npm):
35 35 'jquery.js'
36 36 , 'jquery.client.js'
37 37 ]
  38 + , 'preManipulate': {
  39 + '^': [
  40 + assetHandler.snockets
  41 + ]
  42 + }
38 43 , 'postManipulate': {
39 44 '^': [
40 45 assetHandler.uglifyJsOptimize
@@ -45,6 +50,8 @@ Via [npm](http://github.com/isaacs/npm):
45 50 ## Handlers
46 51 ### uglifyJsOptimize
47 52 Uses UglifyJS to compress the give javascript files.
  53 +### snockets
  54 +Uses Sprockets/Snockets-style comments to indicate javascript dependencies using //= require dependency and //= require_tree dir
48 55 ### yuiJsOptimize
49 56 Uses YUI Compressor to compress the given javascript files.
50 57 ### yuiCssOptimize
11 lib/handlers.js
@@ -7,6 +7,8 @@ var step = require('step');
7 7 var uglifyParser = require('uglify-js').parser;
8 8 var uglifyProcess = require('uglify-js').uglify;
9 9 var YahooCssMin = require("../deps/cssmin");
  10 +var Snockets = require('snockets');
  11 +var snockets = new Snockets();
10 12 module.exports = new handlers();
11 13
12 14
@@ -59,6 +61,15 @@ function handlers()
59 61 ast = uglifyProcess.ast_squeeze(ast);
60 62 callback(uglifyProcess.gen_code(ast));
61 63 };
  64 + this.snockets = function(file, path, index, isLast, callback) {
  65 + snockets.getConcatenation(path, function(err, js) {
  66 + if (js) {
  67 + callback(js);
  68 + } else {
  69 + callback(err);
  70 + }
  71 + });
  72 + };
62 73 this.fixGradients = function (file, path, index, isLast, callback) {
63 74 callback(file.replace(/gradient: *([^_]+)_([^;]+);/g, function(str, c1, c2) {
64 75 var msieC = [];
1  package.json
@@ -9,6 +9,7 @@
9 9 "repository" : { "type":"git", "url":"http://github.com/mape/connect-assetmanager-handlers.git" },
10 10 "dependencies" : {
11 11 "request" : ">=0.9.5",
  12 + "snockets": ">=1.3.7",
12 13 "step" : ">=0.0.3",
13 14 "uglify-js" : ">=0.0.1"
14 15 }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.