File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ import postcss from 'postcss' ;
2+ import genericNames from 'generic-names' ;
3+
4+ import Values from 'postcss-modules-values' ;
5+ import LocalByDefault from 'postcss-modules-local-by-default' ;
6+ import ExtractImports from 'postcss-modules-extract-imports' ;
7+ import Scope from 'postcss-modules-scope' ;
8+ import Parser from './parser' ;
9+
10+ /**
11+ * @param {array } options.append
12+ * @param {array } options.prepend
13+ * @param {array } options.use
14+ * @param {function } options.createImportedName
15+ * @param {function|string } options.generateScopedName
16+ * @param {string } options.mode
17+ * @param {string } options.rootDir
18+ * @param {function } fetch
19+ * @return {object }
20+ */
21+ export function get ( {
22+ append = [ ] ,
23+ prepend = [ ] ,
24+ createImportedName,
25+ generateScopedName,
26+ mode,
27+ use,
28+ rootDir : context = process . cwd ( ) ,
29+ } = { } , fetch ) {
30+ if ( typeof generateScopedName !== 'function' ) {
31+ generateScopedName = genericNames ( generateScopedName || '[name]__[local]___[hash:base64:5]' , { context} ) ;
32+ }
33+
34+ const plugins = use || [
35+ ...prepend ,
36+ Values ,
37+ mode
38+ ? new LocalByDefault ( { mode} )
39+ : LocalByDefault ,
40+ createImportedName
41+ ? new ExtractImports ( { createImportedName} )
42+ : ExtractImports ,
43+ new Scope ( { generateScopedName} ) ,
44+ ...append ,
45+ ] ;
46+
47+ plugins . push ( new Parser ( { fetch} ) ) ;
48+ return postcss ( plugins ) ;
49+ }
You can’t perform that action at this time.
0 commit comments