Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加缓存编译依赖,处理import缓存问题 #10

Merged
merged 2 commits into from
Jun 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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