Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds Stylus compiler.

  • Loading branch information...
commit 09d992e361771110cce617739bd0c151a03c7f69 1 parent 60a163d
@dsc authored
Showing with 69 additions and 30 deletions.
  1. +25 −21 README.md
  2. +12 −5 TODO.md
  3. +27 −1 compiler.co
  4. +5 −3 package.co
View
46 README.md
@@ -1,10 +1,10 @@
-## connect-compiler
+# connect-compiler
-[`connect`](http://senchalabs.github.com/connect/) middleware for dynamically recompiling derived files at serve-time. This module is designed for speeding up development; best-practices would have you compile all necessary files as part of your production deploy process.
+[`connect`](http://senchalabs.github.com/connect/) middleware for dynamically recompiling derived files at serve-time. This module is designed for speeding up development; best-practices would have you compile all necessary files as part of your production deploy process. But you knew that, of course.
Usage is the same as all other `connect` middleware:
-````javascript
+````js
var connect = require('connect')
, compiler = require('connect-compiler')
@@ -17,13 +17,14 @@ Usage is the same as all other `connect` middleware:
}),
connect.static(__dirname + '/public'),
connect.static(__dirname + '/var')
- );
+ )
+ ;
server.listen(6969);
````
-### Settings
+## Settings
The compiler middleware takes a settings object, minimally containing a list of compilers to enable (`enabled`). Most uses will also specify a source directory (`src`).
@@ -237,54 +238,57 @@ The compiler middleware takes a settings object, minimally containing a list of
-### Compilers
+## Compilers
-- #### CoffeeScriptCompiler
+- ### CoffeeScriptCompiler
-- #### CocoCompiler
+- ### CocoCompiler
-- #### CommonJSCompiler
+- ### CommonJSCompiler
-- #### UglifyCompiler
+- ### UglifyCompiler
-- #### JadeCompiler
+- ### JadeCompiler
-- #### LessCompiler
+- ### StylusCompiler
-- #### SassJSCompiler
+- ### LessCompiler
-- #### SassRubyCompiler
+- ### SassJSCompiler
-- #### JisonCompiler
+- ### SassRubyCompiler
-- #### YamlCompiler
+- ### JisonCompiler
+
+
+- ### YamlCompiler
-### API
+## API
-- #### CompilerMiddleware(settings={}, ...custom)
+- ### CompilerMiddleware(settings={}, ...custom)
-- #### Compiler
+- ### Compiler
-- #### ExternalCompiler
+- ### ExternalCompiler
-### Feedback
+## Feedback
View
17 TODO.md
@@ -1,11 +1,17 @@
# todo
-- Bug: compiler errors propagate to node
+- **Bug:** compiler errors sometimes propagate to node?! well shit son, somebody needs tests.
+- Remove `yaml-python`, `CommonJS` compilers and create a `connect-compiler-extras` package for myself.
+
+## later
+- Restructure middleware responder to use events to trigger compiler phases, remove `seq`.
+- Make `setup()` a simple proxy to `CompilerMiddleware` class.
+- Add post-`write()` cleanup/finally event (which fires whether successful or not).
+- GitHub site with introduction, documentation.
- Replace `#token` in config Strings.
-- Make `setup()` a simple proxy to CompilerMiddleware class.
-- Restructure middleware responder to use events to trigger compiler phases.
-## todoc
+
+## docs
- examples:
- simple usage
@@ -16,10 +22,11 @@
- extending an existing compiler
- per-compiler documentation, options
+
## New Compilers
- Haml
-- Stylus
+- yaml-js
- Bundler: cat together multiple files (recursive compiler)
View
28 compiler.co
@@ -348,7 +348,7 @@ class exports.Compiler extends EventEmitter
if info.create_dirs
mkdirp path.dirname(info.dest), 8r0755, this
else
- this.ok()
+ @ok()
.seq ->
c.destValid info.dest, this
.seq (info.destStat) ->
@@ -514,6 +514,28 @@ class exports.JadeCompiler extends Compiler
### CSS Compilers
+class exports.StylusCompiler extends Compiler
+ id : 'stylus'
+ match : /\.css$/i
+ ext : '.styl'
+ module : 'stylus'
+
+ -> super ...
+ compile : (text, options={}, cb) ->
+ stylus = @module(text)
+
+ options.filename = @info.src
+ for k, v in options
+ if k is 'nib' and v
+ stylus.use nib()
+ else if <[ use import include ]>.indexOf(k) is not -1
+ stylus[k](v)
+ else
+ stylus.set k, v
+
+ stylus.render cb
+
+
class exports.LessCompiler extends Compiler
id : 'less'
match : /\.css$/i
@@ -568,12 +590,15 @@ class exports.YamlCompiler extends ExternalCompiler
+# Register Compilers
+
cs =
CoffeeScriptCompiler
CocoCompiler
CommonJSCompiler
UglifyCompiler
JadeCompiler
+ StylusCompiler
LessCompiler
SassJSCompiler
SassRubyCompiler
@@ -583,6 +608,7 @@ cs =
for c of cs then register c
+
### Helpers
expand = (...parts) ->
View
8 package.co
@@ -2,15 +2,17 @@ name : 'connect-compiler'
version : '0.0.1'
description : 'Dynamically recompile stale assets'
homepage : 'http://dsc.github.com/connect-compiler'
-keywords : [ 'connect', 'middleware', 'compiler', 'development', 'coffee-script', 'jade', 'css', 'minify' ]
+keywords : [ 'connect', 'middleware', 'compiler', 'development', 'coffee-script', 'coco', 'jade', 'stylus', 'less', 'css', 'minify' ]
author : name:'David Schoonover', email:'dsc@less.ly', url:'http://less.ly'
+
main : 'compiler'
-# scripts : test:'expresso'
+scripts : test:'expresso'
dependencies :
seq : '>= 0.3.4'
devDependencies :
coco : '>= 0.6.7'
- # expresso : '>=0.7.x'
+ expresso : '>=0.7.x'
+
repository : type:'git', url:'git://github.com/dsc/connect-compiler.git'
bugs : url:'http://github.com/dsc/connect-compiler/issues'
engine : node : '>=0.4.0'
Please sign in to comment.
Something went wrong with that request. Please try again.