Skip to content

Commit

Permalink
Merge pull request #10 from hefangshi/fix-cache-deps
Browse files Browse the repository at this point in the history
添加缓存编译依赖,处理import缓存问题
  • Loading branch information
2betop committed Jun 9, 2014
2 parents 6a5405e + 2774ba9 commit 0dcac49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var map = (function() {
wrap: function( value ) {
return '/*embed:' + value + '*/';
}
}
};
})();

var sass = require('fis-sass');
Expand Down Expand Up @@ -153,14 +153,16 @@ var compile = module.exports = function( content, file, opts ) {
}

cache = {};
opts.data = before( content, file.ext, unique( opts.include_paths ) );
opts.data = before( content, file, unique( opts.include_paths ) );
content = sass.renderSync( opts );
content = after( content, file.ext, opts.include_paths );
content = after( content, file, opts.include_paths );

return content;
}
};

var before = compile.before = function( content, currentFile, paths) {

var before = compile.before = function( content, ext, paths ) {
var ext = currentFile.ext;

paths = unique( paths );

Expand All @@ -181,6 +183,7 @@ var before = compile.before = function( content, ext, paths ) {
return '';
}

currentFile.cache.addDeps(file.realpath);
stack[ file.realpath ] = true;
cache[ file.realpath ] = true;

Expand All @@ -189,7 +192,7 @@ var before = compile.before = function( content, ext, paths ) {
content = sass.sass2scss( content );
}

content = before( content, file.ext, [ file.dirname ].concat( paths ) );
content = before( content, file, [ file.dirname ].concat( paths ) );

delete stack[ file.realpath ];

Expand All @@ -202,6 +205,6 @@ var before = compile.before = function( content, ext, paths ) {
});
};

var after = compile.after = function( content, ext, paths ) {
var after = compile.after = function( content, currentFile, paths ) {
return content;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "fis-parser-sass",
"description" : "A parser plugin for fis to compile sass file.",
"version" : "0.1.2",
"version" : "0.1.3",
"author" : "FIS Team <[email protected]>",
"homepage" : "http://fis.baidu.com/",
"keywords": [ "fis", "sass" ],
Expand Down

0 comments on commit 0dcac49

Please sign in to comment.