-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpostcss.config.js
44 lines (40 loc) · 1.45 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
const postcssPresetEnv = require('postcss-preset-env')
const postcssSafeArea = require('postcss-safe-area')
const postcssShortSize = require('postcss-short-size')
/**
* Experimental plugin the CSS `:has` pseudo-selector. It requires to run the
* following on the browser side:
*
* ```js
* import cssHasPseudo from '@csstools/css-has-pseudo-experimental/browser'
* cssHasPseudo(document)
* ```
*
* - https://developer.mozilla.org/en-US/docs/Web/CSS/:has
* - https://github.com/csstools/postcss-plugins/tree/main/experimental
*/
const cssHasPseudoExperimental = require('@csstools/css-has-pseudo-experimental')
const cssNano = require('cssnano')
const postcssPresetEnvOptions = {
stage: 0,
features: {
// https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/src/plugins/plugins-by-id.mjs
'all-property': false,
'color-functional-notation': false,
'focus-within-pseudo-class': false,
'focus-visible-pseudo-class': false,
'logical-properties-and-values': { dir: 'ltr' },
'prefers-color-scheme-query': false,
'has-pseudo-class': false, // defect, experimental version used instead
},
}
const cssNanoOptions = { preset: ['default', { colormin: false }] }
module.exports = ({ options, env }) => ({
plugins: [
postcssShortSize(),
postcssSafeArea(),
postcssPresetEnv(postcssPresetEnvOptions),
cssHasPseudoExperimental(),
env === 'production' ? cssNano(cssNanoOptions) : false,
],
})