Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added less on Node.js Web framework usage #6

Merged
merged 1 commit into from

2 participants

@iwillwen

No description provided.

@feichang feichang merged commit edb413e into feichang:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 30, 2013
  1. @iwillwen
This page is out of date. Refresh to see the latest.
Showing with 36 additions and 1 deletion.
  1. +36 −1 translate/1.3.3/overview.html
View
37 translate/1.3.3/overview.html
@@ -279,9 +279,44 @@
});
</code></pre>
+<h2>Node.js中Web框架的使用方法</h2>
+<p>你可以通过Node.js中的Web开发框架(如webjs, express等)使用Less。</p>
+<pre><code>var web = require('webjs');
+
+web.run()
+ .use(
+ web.compiler({ enable: [ 'less' ] }),
+ '/static', web.static(__dirname + '/assert')
+ );
+
+console.log('Simple HTTP Server is running on http://localhost');</code></pre>
+<p>此后,你可以在前端页面中如此使用经过服务器编译的Less样式文件,而无需再引入less.js文件。</p>
+<pre><code>&lt;link rel="stylesheet" type="text/css" href="/static/style/main.less"&gt;</code></pre>
+<h3>express</h3>
+<pre><code>var express = require('express');
+var lessMiddleware = require('less-middleware');
+
+var app = express();
+
+app.configure(function () {
+
+ app.use(lessMiddleware({
+ src: __dirname + '/assert',
+ compress: true
+ }));
+ app.use('/static', express.static(__dirname + '/assert'));
+
+});
+
+app.listen(80);
+
+console.log('Simple HTTP Server is running on http://localhost');</code></pre>
+<p>通过express编译的less文件需要在前端页面以css后缀名引入。</p>
+<pre><code>&lt;link rel="stylesheet" type="text/css" href="/static/style/main.css"&gt;</code></pre>
+
<h2>第三方工具</h2>
<p><a href="http://less.cnodejs.net/tools">工具汇总</a></p>
</div>
-</section>
+</section>
Something went wrong with that request. Please try again.