1 | 'use strict'
|
2 |
|
3 | const req = require('import-cwd')
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | const options = (config, file) => {
|
16 | if (config.parser && typeof config.parser === 'string') {
|
17 | try {
|
18 | config.parser = req(config.parser)
|
19 | } catch (err) {
|
20 | throw new Error(`Loading PostCSS Parser failed: ${err.message}\n\n(@${file})`)
|
21 | }
|
22 | }
|
23 |
|
24 | if (config.syntax && typeof config.syntax === 'string') {
|
25 | try {
|
26 | config.syntax = req(config.syntax)
|
27 | } catch (err) {
|
28 | throw new Error(`Loading PostCSS Syntax failed: ${err.message}\n\n(@${file})`)
|
29 | }
|
30 | }
|
31 |
|
32 | if (config.stringifier && typeof config.stringifier === 'string') {
|
33 | try {
|
34 | config.stringifier = req(config.stringifier)
|
35 | } catch (err) {
|
36 | throw new Error(`Loading PostCSS Stringifier failed: ${err.message}\n\n(@${file})`)
|
37 | }
|
38 | }
|
39 |
|
40 | if (config.plugins) {
|
41 | delete config.plugins
|
42 | }
|
43 |
|
44 | return config
|
45 | }
|
46 |
|
47 | module.exports = options
|