-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpostcss.config.js
42 lines (33 loc) · 1009 Bytes
/
postcss.config.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const fs = require('fs');
const workspaceConfig = require('./workspace.json');
const TAILWIND_CONFIG_FILE = 'tailwind.config.js';
const targetDescriptionStr = process.argv.at(-1);
const {
targetDescription: { project, target },
} = targetDescriptionStr
? JSON.parse(targetDescriptionStr)
: { project: undefined, target: '' };
const STORYBOOK_REGEX = /storybook/gi;
let plugins = { autoprefixer: {} };
const projectConfig = workspaceConfig.projects[project];
if (
projectConfig &&
(STORYBOOK_REGEX.test(target) || projectConfig.projectType === 'application')
) {
let config = undefined;
if (fs.existsSync(`${projectConfig.root}/${TAILWIND_CONFIG_FILE}`)) {
config = `./${projectConfig.root}/${TAILWIND_CONFIG_FILE}`;
} else if (fs.existsSync(TAILWIND_CONFIG_FILE)) {
config = `./${TAILWIND_CONFIG_FILE}`;
}
if (config) {
plugins = {
'postcss-import': {},
tailwindcss: { config: `${config}` },
...plugins,
};
}
}
module.exports = {
plugins,
};