less-loader
Advanced tools
Comparing version 0.6.0 to 0.6.1
49
index.js
@@ -17,4 +17,10 @@ /* | ||
var errored = false; | ||
less.Parser.importer = function (file, paths, callback, env) { | ||
var context = path.dirname(env._parentFilename || env.filename); | ||
less.Parser.fileLoader = function (file, currentFileInfo, callback, env) { | ||
var newFileInfo = { | ||
relativeUrls: env.relativeUrls, | ||
entryPath: currentFileInfo.entryPath, | ||
rootpath: currentFileInfo.rootpath, | ||
rootFilename: currentFileInfo.rootFilename | ||
}; | ||
var context = currentFileInfo.currentDirectory; | ||
var moduleName = urlToRequire(file) | ||
@@ -29,22 +35,14 @@ if(cb) { | ||
} | ||
loaderContext.dependency && loaderContext.dependency(filename); | ||
newFileInfo.filename = filename; | ||
newFileInfo.currentDirectory = path.dirname(filename); | ||
// The default (asynchron) | ||
fs.readFile(filename, 'utf-8', function(e, data) { | ||
if (e) return callback(e); | ||
loaderContext.loadModule("-!" + __dirname + "/stringify.loader.js!" + filename, function(err, data) { | ||
if(err) { | ||
if(!errored) | ||
loaderContext.callback(err); | ||
errored = true; | ||
return; | ||
} | ||
try { | ||
new(less.Parser)({ | ||
_parentFilename: filename, | ||
paths: [], | ||
compress: env.compress | ||
}).parse(data, function (e, root) { | ||
callback(e, root, data); | ||
}); | ||
} catch(e) { | ||
try { | ||
callback(e); | ||
} catch(e) { | ||
loaderContext.callback(formatLessError(e, filename)); | ||
} | ||
} | ||
callback(null, JSON.parse(data), filename, newFileInfo); | ||
}); | ||
@@ -54,12 +52,9 @@ }); | ||
var filename = loaderContext.resolveSync(context, moduleName); | ||
loaderContext.dependency && loaderContext.dependency(filename); | ||
newFileInfo.filename = filename; | ||
newFileInfo.currentDirectory = path.dirname(filename); | ||
// Make it synchron | ||
try { | ||
var data = fs.readFileSync(filename, 'utf-8'); | ||
new(less.Parser)({ | ||
_parentFilename: filename, | ||
paths: [], | ||
compress: env.compress | ||
}).parse(data, function (e, root) { | ||
callback(e, root, data); | ||
}); | ||
callback(null, data, filename, newFileInfo); | ||
} catch(e) { | ||
@@ -66,0 +61,0 @@ try { |
{ | ||
"name": "less-loader", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "less loader module for webpack", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3209
5
87