-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathless-compile-cache.coffee
36 lines (29 loc) · 1.1 KB
/
less-compile-cache.coffee
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
path = require 'path'
LessCache = require 'less-cache'
# {LessCache} wrapper used by {ThemeManager} to read stylesheets.
module.exports =
class LessCompileCache
constructor: ({resourcePath, importPaths, lessSourcesByRelativeFilePath, importedFilePathsByRelativeImportPath}) ->
cacheDir = path.join(process.env.ATOM_HOME, 'compile-cache', 'less')
@lessSearchPaths = [
path.join(resourcePath, 'static', 'variables')
path.join(resourcePath, 'static')
]
if importPaths?
importPaths = importPaths.concat(@lessSearchPaths)
else
importPaths = @lessSearchPaths
@cache = new LessCache({
importPaths,
resourcePath,
lessSourcesByRelativeFilePath,
importedFilePathsByRelativeImportPath,
cacheDir,
fallbackDir: path.join(resourcePath, 'less-compile-cache')
})
setImportPaths: (importPaths=[]) ->
@cache.setImportPaths(importPaths.concat(@lessSearchPaths))
read: (stylesheetPath) ->
@cache.readFileSync(stylesheetPath)
cssForFile: (stylesheetPath, lessContent, digest) ->
@cache.cssForFile(stylesheetPath, lessContent, digest)