mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-14 05:50:20 +00:00
add preprocessors to plugins
This commit is contained in:
@@ -11,3 +11,27 @@ less.render("fail").then((output) => {
|
||||
}, (error: Less.RenderError) => {
|
||||
console.log("rejected as expected on line number " + error.line);
|
||||
});
|
||||
|
||||
var preProcessor: Less.PreProcessor = {
|
||||
process: (src, extra) => {
|
||||
console.log(extra.imports, extra.context);
|
||||
if (extra.fileInfo.filename === "foo.less") {
|
||||
return ".other-rule { width: (1 + 1); }\n " + src;
|
||||
} else {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var myPlugin: Less.Plugin = {
|
||||
install: (less, pluginManager) => {
|
||||
alert(less.version[2]);
|
||||
pluginManager.addPreProcessor(preProcessor, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
var options: Less.Options = {
|
||||
plugins: [myPlugin]
|
||||
};
|
||||
|
||||
less.render("h1 { background: red; }", options);
|
||||
|
||||
Vendored
+18
@@ -30,12 +30,30 @@ declare module Less {
|
||||
|
||||
class PluginManager {
|
||||
constructor(less: LessStatic);
|
||||
|
||||
addPreProcessor(preProcessor: PreProcessor, priority?: number): void;
|
||||
}
|
||||
|
||||
interface Plugin {
|
||||
install: (less: LessStatic, pluginManager: PluginManager) => void;
|
||||
}
|
||||
|
||||
interface PreProcessor {
|
||||
process: (src: string, extra: PreProcessorExtraInfo) => string;
|
||||
}
|
||||
|
||||
interface PreProcessorExtraInfo {
|
||||
context: {
|
||||
pluginManager: PluginManager;
|
||||
};
|
||||
|
||||
fileInfo: RootFileInfo;
|
||||
|
||||
imports: {
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
interface SourceMapOption {
|
||||
sourceMapURL: string;
|
||||
sourceMapBasepath: string;
|
||||
|
||||
Reference in New Issue
Block a user