| 83 | |
| 84 | // .less |
| 85 | const less: StylePreprocessor = (source, map, options, load = require) => { |
| 86 | const nodeLess = load('less') |
| 87 | |
| 88 | let result: any |
| 89 | let error: Error | null = null |
| 90 | nodeLess.render( |
| 91 | getSource(source, options.filename, options.additionalData), |
| 92 | { ...options, syncImport: true }, |
| 93 | (err: Error | null, output: any) => { |
| 94 | error = err |
| 95 | result = output |
| 96 | }, |
| 97 | ) |
| 98 | |
| 99 | if (error) return { code: '', errors: [error], dependencies: [] } |
| 100 | const dependencies = result.imports |
| 101 | if (map) { |
| 102 | return { |
| 103 | code: result.css.toString(), |
| 104 | map: merge(map, result.map), |
| 105 | errors: [], |
| 106 | dependencies: dependencies, |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | return { |
| 111 | code: result.css.toString(), |
| 112 | errors: [], |
| 113 | dependencies: dependencies, |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // .styl |
| 118 | const styl: StylePreprocessor = (source, map, options, load = require) => { |