-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (21 loc) · 886 Bytes
/
index.js
File metadata and controls
28 lines (21 loc) · 886 Bytes
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
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 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 )
const result = postcss( this.plugins.concat( [parser.plugin] ) )
.process( sourceString, { from: "/" + sourcePath } )
return { injectableSource: result.css, exportTokens: parser.exportTokens }
}
}
// These three plugins are aliased under this package for simplicity.
Core.localByDefault = localByDefault
Core.extractImports = extractImports
Core.scope = scope
Core.defaultPlugins = [localByDefault, extractImports, scope]