Skip to content

Commit c07f2e7

Browse files
committed
update example
1 parent dfa040f commit c07f2e7

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
exports.install = function(framework) {
1+
exports.install = function() {
22
framework.route('/');
33
};
Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
var sass = require('node-sass');
2+
var Fs = require('fs');
23

3-
framework.onCompileStyle = function (filename, content) {
4-
// if filename === '' then it is the inline style
5-
return sass.renderSync({ data: content, outputStyle: 'compressed' }).css;
4+
F.accept('scss', 'text/css');
5+
6+
F.helpers.scss = function(name) {
7+
return '<link type="text/css" rel="stylesheet" href="' + F.routeStyle(name).replace(/\.css$/, '') + '" />';
8+
};
9+
10+
F.file('*.scss', function(req, res, is) {
11+
if (is)
12+
return req.extension === 'scss';
13+
14+
F.exists(req, res, 20, function(next, tmp) {
15+
var filename = F.path.public(req.url);
16+
Fs.readFile(filename, function(err, data) {
17+
18+
if (err) {
19+
next();
20+
res.throw404();
21+
return;
22+
}
23+
24+
var content = F.onCompileStyle(filename, data.toString('utf8'));
25+
if (!F.isDebug)
26+
Fs.writeFile(tmp, content);
27+
F.responseContent(req, res, 200, content, 'text/css', true);
28+
});
29+
});
30+
});
31+
32+
F.onCompileStyle = function (filename, content) {
33+
return sass.renderSync({ data: content, outputStyle: 'compressed' }).css.toString('utf8');
634
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$blue: #3bbfce;
2+
3+
.content {
4+
border: 2px solid $blue;
5+
}

external-compile-sass/views/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<meta name="viewport" content="width=1024, user-scalable=yes" />
1111
<meta name="robots" content="all,follow" />
1212
@{css('default.css')}
13+
@{scss('default.scss')}
1314

1415
<!-- DYNAMIC COMPRESS -->
1516
<style type="text/css">

0 commit comments

Comments
 (0)