fis-parser-sass
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -16,3 +16,3 @@ /** | ||
var stack = {}; | ||
var cache; | ||
var required; | ||
@@ -90,3 +90,3 @@ function fixLineBreak( content ) { | ||
// 自动加后缀。 | ||
if ( !/\.\w+$/.exec( basename ) ) { | ||
if ( !/\.(scss|sass)$/.exec( basename ) ) { | ||
filename = dirname + basename + ext; | ||
@@ -150,5 +150,9 @@ files.push( filename ); | ||
cache = {}; | ||
required = {}; | ||
opts.data = before( content, file, unique( opts.include_paths ) ); | ||
content = sass.renderSync( opts ); | ||
try { | ||
content = sass.renderSync( opts ); | ||
} catch (ex) { | ||
fis.log.error(ex); | ||
} | ||
content = after( content, file, opts.include_paths ); | ||
@@ -161,2 +165,3 @@ | ||
// @todo use cache of this progress. | ||
var ext = currentFile.ext; | ||
@@ -167,2 +172,3 @@ | ||
return _process( content ).replace( map.reg, function( all, value ) { | ||
var file = lookup( value, ext, paths ), | ||
@@ -180,3 +186,3 @@ content; | ||
// 类似与include_once. | ||
if ( cache[ file.realpath ] ) { | ||
if ( required[ file.realpath ] ) { | ||
return ''; | ||
@@ -191,3 +197,3 @@ } | ||
stack[ file.realpath ] = true; | ||
cache[ file.realpath ] = true; | ||
required[ file.realpath ] = true; | ||
@@ -194,0 +200,0 @@ content = file.getContent(); |
{ | ||
"name" : "fis-parser-sass", | ||
"description" : "A parser plugin for fis to compile sass file.", | ||
"version" : "0.2.0", | ||
"version" : "0.2.1", | ||
"author" : "FIS Team <fis@baidu.com>", | ||
@@ -6,0 +6,0 @@ "homepage" : "http://fis.baidu.com/", |
@@ -1,3 +0,40 @@ | ||
#在项目中使用sass和compass | ||
fis-parser-sass | ||
============================ | ||
## 安装与使用 | ||
全局安装 | ||
```bash | ||
npm install fis-parser-sass -g | ||
``` | ||
开启插件 | ||
```javascript | ||
fis.config.merge('modules.parser', { | ||
sass : 'sass', | ||
scss: 'sass' | ||
}); | ||
fis.config.merge('roadmap.ext', { | ||
sass: 'css', | ||
scss: 'css' | ||
}); | ||
``` | ||
插件配置 | ||
```javascript | ||
fis.config.set('settings.parser.sass', { | ||
// 加入文件查找目录 | ||
include_paths: [] | ||
}); | ||
``` | ||
## 在项目中使用sass和compass | ||
有了 ``fis-parser-sass`` 就可用用compass了,方法如下: | ||
@@ -11,3 +48,3 @@ | ||
1. 下载 [compass](https://github.com/chriseppstein/compass) 框架,把框架中的 ``frameworks/compass/stylesheets`` 目录下的文件放到你的项目中,得到目录结构: | ||
1. 下载 [compass](https://github.com/Igosuki/compass-mixins) 框架,把框架中的 ``frameworks/compass/stylesheets`` 目录下的文件放到你的项目中,得到目录结构: | ||
@@ -14,0 +51,0 @@ ``` |
9850
183
96