88 *
99 * @todo Find a way to do not use deasync
1010 */
11- import postcss from 'postcss'
12- import safeParse from 'postcss-safe-parser'
1311import postcssJs from 'postcss-js'
14- import postcssrc from 'postcss-load-config'
1512import deasync from 'deasync'
1613
17- let config
18- let processor
19-
20- /**
21- * 1. Initiate config, options and processor variables in module scope,
22- * if they are not initiated yet
23- *
24- * 2. Process parsing with initiated options
25- *
26- * @param {String } rawStyles
27- * @param {Object } processOptions
28- * @returns {Object } JSS Object
29- */
30- const processParsing = async ( rawStyles , processOptions = { } ) => {
31- const { config : customConfig } = processOptions
32- if ( ! config && customConfig ) {
33- config = customConfig
34- } else if ( ! config ) {
35- config = await postcssrc ( )
36- }
37-
38- const { plugins = [ ] , options = { } } = config
39- const finalOptions = { parser : safeParse , ...options }
40-
41- if ( ! processor ) {
42- processor = postcss ( plugins )
43- }
44-
45- return processor . process ( rawStyles , finalOptions )
46- }
14+ import processParsing from '../common/process-parsing'
4715
4816/**
4917 * Parse specified Tagged Template Strings with CSS and expressions
@@ -58,6 +26,3 @@ export default deasync((rawStyles, processOptions = {}, cb) => {
5826 . then ( result => cb ( null , result ) )
5927 . catch ( error => cb ( error ) )
6028} )
61-
62-
63-
0 commit comments