-
Notifications
You must be signed in to change notification settings - Fork 0
/
postcss.config.js
50 lines (47 loc) · 1.32 KB
/
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
43
44
45
46
47
48
49
50
/* eslint-disable @typescript-eslint/naming-convention */
import postcssImport from 'postcss-import';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import * as p from 'node:path';
import { postcssFontGrabber } from 'postcss-font-grabber';
// @ts-expect-error
import postcssImportUrl from 'postcss-import-url';
import postcssNested from 'postcss-nested';
// @ts-expect-error
import postcssMixins from 'postcss-mixins';
const dirname = p.dirname(new URL(import.meta.url).pathname);
const mode = process.env['NODE_ENV'];
const production = mode !== 'development';
export default {
/** @type {import('postcss').Plugin[]} */
plugins: [
postcssImportUrl({
modernBrowser: true,
}),
postcssMixins({
mixinsDir: p.join(dirname, 'src/theme/'),
}),
postcssImport(),
postcssFontGrabber({
cssDest: '.',
fontDest: 'static/_font',
}),
{
postcssPlugin: 'remove "static" from postcss-font-grabber result',
AtRule(rule) {
if (rule.name !== 'font-face') return;
for (const node of rule.nodes) {
if (!(node.type === 'decl' && node.prop === 'src'))
continue;
node.value = node.value.replace(/\(static/g, '(');
}
},
},
postcssNested(),
autoprefixer(),
production &&
cssnano({
preset: 'default',
}),
],
};