Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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
Commits on Jun 14, 2012
  1. Prabir Shrestha

    added snockets handler

    prabirshrestha authored
  2. Prabir Shrestha
  3. Prabir Shrestha

    removed return

    prabirshrestha authored
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 0 deletions.
  1. +7 −0 README.md
  2. +11 −0 lib/handlers.js
  3. +1 −0  package.json
7 README.md
View
@@ -35,6 +35,11 @@ Via [npm](http://github.com/isaacs/npm):
'jquery.js'
, 'jquery.client.js'
]
+ , 'preManipulate': {
+ '^': [
+ assetHandler.snockets
+ ]
+ }
, 'postManipulate': {
'^': [
assetHandler.uglifyJsOptimize
@@ -45,6 +50,8 @@ Via [npm](http://github.com/isaacs/npm):
## Handlers
### uglifyJsOptimize
Uses UglifyJS to compress the give javascript files.
+### snockets
+Uses Sprockets/Snockets-style comments to indicate javascript dependencies using //= require dependency and //= require_tree dir
### yuiJsOptimize
Uses YUI Compressor to compress the given javascript files.
### yuiCssOptimize
11 lib/handlers.js
View
@@ -7,6 +7,8 @@ var step = require('step');
var uglifyParser = require('uglify-js').parser;
var uglifyProcess = require('uglify-js').uglify;
var YahooCssMin = require("../deps/cssmin");
+var Snockets = require('snockets');
+var snockets = new Snockets();
module.exports = new handlers();
@@ -59,6 +61,15 @@ function handlers()
ast = uglifyProcess.ast_squeeze(ast);
callback(uglifyProcess.gen_code(ast));
};
+ this.snockets = function(file, path, index, isLast, callback) {
+ snockets.getConcatenation(path, function(err, js) {
+ if (js) {
+ callback(js);
+ } else {
+ callback(err);
+ }
+ });
+ };
this.fixGradients = function (file, path, index, isLast, callback) {
callback(file.replace(/gradient: *([^_]+)_([^;]+);/g, function(str, c1, c2) {
var msieC = [];
1  package.json
View
@@ -9,6 +9,7 @@
"repository" : { "type":"git", "url":"http://github.com/mape/connect-assetmanager-handlers.git" },
"dependencies" : {
"request" : ">=0.9.5",
+ "snockets": ">=1.3.7",
"step" : ">=0.0.3",
"uglify-js" : ">=0.0.1"
}
Something went wrong with that request. Please try again.