forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
less-middleware.d.ts
108 lines (86 loc) · 3.24 KB
/
less-middleware.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Type definitions for less-middleware 2.0.1
// Project: https://github.com/emberfeather/less.js-middleware
// Definitions by: Federico Bond <https://github.com/federicobond/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/* =================== USAGE ===================
import lessMiddleware = require('less-middleware');
app.use(lessMiddleware(source, options));
=============================================== */
/// <reference path="../express/express.d.ts" />
declare module "less-middleware" {
import express = require('express');
/**
* Middleware created to allow processing of Less files for Connect JS framework
* and by extension the Express JS framework
*/
function lessMiddleware(source: string, options?: {
/**
* Show more verbose logging?
*/
debug?: boolean;
/**
* Destination directory to output the compiled .css files.
*/
dest?: string;
/**
* Always re-compile less files on each request.
*/
force?: boolean;
/**
* Only recompile once after each server restart.
* Useful for reducing disk i/o on production.
*/
once?: boolean;
/**
* Common root of the source and destination.
* It is prepended to both the source and destination before being used.
*/
pathRoot?: string;
/**
* Object containing functions relevant to preprocessing data.
*/
postprocess?: {
/**
* Function that modifies the compiled css output before being stored.
*/
css?(css: string, req: express.Request): string;
};
/**
* Object containing functions relevant to preprocessing data.
*/
preprocess?: {
/**
* Function that modifies the raw less output before being parsed and compiled.
*/
less?(css: string, req: express.Request): string;
/**
* Function that modifies the less pathname before being loaded from the filesystem.
*/
path?(pathname: string, req: express.Request): string;
/**
* Function that modifies the import paths used by the less parser per request.
*/
importPaths?(paths: string[], req: express.Request): string[];
};
/**
* Options for the less render.
*/
render?: {
compress?: string;
yuicompress?: boolean;
paths?: string[];
};
/**
* Function that is in charge of storing the css in the filesystem.
*/
storeCss?(pathname: string, css: string, req: express.Request, next: Function): void;
/**
* Path to a JSON file that will be used to cache less data across server restarts.
* This can greatly speed up initial load time after a server restart - if the less
* files haven't changed and the css files still exist, specifying this option will
* mean that the less files don't need to be recompiled after a server restart.
*/
cacheFile?: string;
}): express.RequestHandler;
export = lessMiddleware;
}