-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathindex.js
28 lines (23 loc) · 928 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
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 );
return postcss( this.plugins.concat( [parser.plugin] ) )
.process( sourceString, { from: '/' + sourcePath } )
.then( result => {
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];