jcs-middleware
Version:
Jade, CoffeeScript, Stylus middleware for Express.js
119 lines (77 loc) • 4.21 kB
HTML
<p><!-- vim: set et ai nu ts=4 sw=4 cc=80: --></p>
<pre><code> ____._________ _________
| |\_ ___ \ / _____/
| |/ \ \/ \_____ \
/\__| |\ \____/ \
\________| \______ /_______ /
\/ \/
.__ .___ .___.__
_____ |__| __| _/__| _/| | ______ _ _______ _______ ____
/ \| |/ __ |/ __ | | | _/ __ \ \/ \/ /\__ \\_ __ \_/ __ \
| Y Y \ / /_/ / /_/ | | |_\ ___/\ / / __ \| | \/\ ___/
|__|_| /__\____ \____ | |____/\___ >\/\_/ (____ /__| \___ >
\/ \/ \/ \/ \/ \/ </code></pre>
<h1>jcs-middleware</h1>
<p>Jade, CoffeeScript, Stylus middleware for Express.js</p>
<h1>Installation</h1>
<p>Use <a href="www.npmjs.org">npm</a> to install jcs-middleware:</p>
<pre><code>npm install jcs-middleware</code></pre>
<h1>Usage</h1>
<h2>In Express app.js</h2>
<pre><code>app.use('/', require('jsc-middleware')(options));</code></pre>
<h2>Options:</h2>
<p><strong>Global options:</strong></p>
<pre><code> debug Output debugging information.
compress Uglify the output, all of them.
force Force compile every time.
staticRoot The root directory of the static files.
urlBase The base url prefix, which should point to <staticRoot></code></pre>
<p><strong>Coffee-script options:</strong></p>
<pre><code> coffeeSrc Source directory used to find .coffee files.
coffeeDst Destination directory where the .js files are stored.
bare Compile JavaScript without the top-level function safty
wrapper.
encodeSrc Encode CoffeeScript source file as base64 comment in
compiled JavaScript.</code></pre>
<p><strong>Stylus options:</strong></p>
<pre><code> stylusSrc Source directory used to find .styl files.
stylusDst Destination directory where the .css files are stored.</code></pre>
<p><strong>Jade options:</strong></p>
<pre><code> jadeSrc Source directory used to find .jade files.
jadeDst Destination directory where the .js files are stored.
jadeStatics Hash map used to generate jade pages.</code></pre>
<p>If any of the <strong>xxxSrc</strong> options is ommit, that feature will be turned off.</p>
<h2>File Path</h2>
<p>Say you have a express website at </p>
<pre><code>http://yourdomain.com/yourapp</code></pre>
<p>Which is located in your server's directory:</p>
<pre><code>/path/to/yourapp</code></pre>
<p>In this app, you store all the static files in <em>public</em> directory, which
means, all access to</p>
<pre><code>http://yourdomain.com/yourapp/XXX</code></pre>
<p>goes to</p>
<pre><code>/path/to/yourapp/public/XXX</code></pre>
<p>Then, you have folder for stylus source files,</p>
<pre><code>/path/to/yourapp/stylus</code></pre>
<p>and you want put the generated css files be put into directory:</p>
<pre><code>/path/to/yourapp/public/css</code></pre>
<p>So that anyone can access those css files from url </p>
<pre><code>http://yourdomain.com/yourapp/css/*.css</code></pre>
<p>In this scenario:</p>
<ul><li><strong>urlBase</strong> is <em>/yourapp</em></li><li><strong>staticRoot</strong> is <em>/path/to/yourapp/public</em></li><li><strong>stylusSrc</strong> is <em>/path/to/yourapp/stylus</em></li><li><strong>stylusDst</strong> is <em>/path/to/yourapp/public/css</em></li></ul>
<p>for example:</p>
<pre><code>+-- path
+-- to
+-- yourapp
+-- public (staticRoot)
| +-- ...
| +-- css (stylusDst)
| +-- ...
| +-- XXX.css <--------+
| |
+-- stylus (stylusSrc) | compile to
+-- ... |
+-- XXX.styl --------+</code></pre>
<p>The same with coffee and jade options.</p>
<h1>License</h1>
<p>MIT (http://www.opensource.org/licenses/mit-license.php)</p>