-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathindex.js
31 lines (25 loc) · 988 Bytes
/
index.js
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
import postcss from 'postcss'
import localByDefault from 'postcss-modules-local-by-default'
import extractImports from 'postcss-modules-extract-imports'
import scope from 'postcss-modules-scope'
import values from 'postcss-modules-values'
import Parser from './parser'
export default class Core {
constructor( plugins ) {
this.plugins = plugins || Core.defaultPlugins
}
load( sourceString, sourcePath, trace, pathFetcher ) {
let parser = new Parser( pathFetcher, trace )
return postcss( this.plugins.concat( [parser.plugin] ) )
.process( sourceString, { from: "/" + sourcePath } )
.then( result => {
return { injectableSource: result.css, exportTokens: parser.exportTokens }
} )
}
}
// These four plugins are aliased under this package for simplicity.
Core.values = values
Core.localByDefault = localByDefault
Core.extractImports = extractImports
Core.scope = scope
Core.defaultPlugins = [values, localByDefault, extractImports, scope]