Skip to content

Commit

Permalink
fix importer and watch md5 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
lwdgit committed Sep 1, 2015
1 parent e912824 commit b693232
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A parser plugin for reasy to compile sass file.
//reasy-conf.js
reasy.match('**.scss', {
rExt: '.css', // from .scss to .css
parser: reasy.plugin('sass')
parser: fis.plugin('sass')
}

```
Expand Down
62 changes: 31 additions & 31 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,37 +145,37 @@ module.exports = function(content, file, conf) {

var includePaths = opts.includePaths;
var sources = [file.subpath];
// opts.importer = function(url, prev, done) {
// var localPaths = includePaths.concat();
// var prevFile = find(prev, includePaths);

// if (prevFile) {
// localPaths.unshift(prevFile.dirname);
// }

// var target = find(url, localPaths);

// if (!target) {
// throw new Error('Can\'t find `' + url +'` in `' + prev + '`');
// }

// var content = target.getContent();
// content = fixSourcePath(content, target);

// if (file.cache) {
// file.cache.addDeps(target.realpath);
// }
// //解决include_path 内import导致subpath为空报错问题
// if(!target.subpath){
// target.subpath = path.relative(root, target.realpath);
// }
// ~sources.indexOf(target.subpath) || sources.push(target.subpath);

// done({
// file: target.subpath,
// contents: content
// });
// };
opts.importer = function(url, prev, done) {
var localPaths = includePaths.concat();
var prevFile = find(prev, includePaths);

if (prevFile) {
localPaths.unshift(prevFile.dirname);
}

var target = find(url, localPaths);

if (!target) {
throw new Error('Can\'t find `' + url +'` in `' + prev + '`');
}

var content = target.getContent();
content = fixSourcePath(content, target);

if (file.cache) {
file.cache.addDeps(target.realpath);
}
//解决include_path 内import导致subpath为空报错问题
if(!target.subpath){
target.subpath = path.relative(root, target.realpath);
}
~sources.indexOf(target.subpath) || sources.push(target.subpath);

return {
file: target.subpath,
contents: content
};
};

if (opts.sourceMap) {

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "reasy-parser-sass",
"description": "A parser plugin for reasy to compile sass file.",
"version": "1.1.6",
"version": "1.1.7",
"keywords": [
"fis",
"sass"
Expand Down

0 comments on commit b693232

Please sign in to comment.