You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
918 B
36 lines
918 B
/**
|
|
* **PostCSS Options Parser**
|
|
*
|
|
* Transforms the loader options into a valid postcss config `{Object}`
|
|
*
|
|
* @method parseOptions
|
|
*
|
|
* @param {Boolean} exec Execute CSS-in-JS
|
|
* @param {String|Object} parser PostCSS Parser
|
|
* @param {String|Object} syntax PostCSS Syntax
|
|
* @param {String|Object} stringifier PostCSS Stringifier
|
|
* @param {Array|Object|Function} plugins PostCSS Plugins
|
|
*
|
|
* @return {Promise} PostCSS Config
|
|
*/
|
|
function parseOptions ({ exec, parser, syntax, stringifier, plugins }) {
|
|
if (typeof plugins === 'function') {
|
|
plugins = plugins.call(this, this)
|
|
}
|
|
|
|
if (typeof plugins === 'undefined') {
|
|
plugins = []
|
|
} else if (!Array.isArray(plugins)) {
|
|
plugins = [ plugins ]
|
|
}
|
|
|
|
const options = {}
|
|
|
|
options.parser = parser
|
|
options.syntax = syntax
|
|
options.stringifier = stringifier
|
|
|
|
return Promise.resolve({ options, plugins, exec })
|
|
}
|
|
|
|
module.exports = parseOptions
|
|
|