-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostcss.config.js
More file actions
53 lines (50 loc) · 1.25 KB
/
postcss.config.js
File metadata and controls
53 lines (50 loc) · 1.25 KB
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
51
52
53
/**
* PostCSS Config
*
* Overrides WP-Scripts default config for postcss processing.
*
* Customizations:
* - postcss-import: Add support for concatenating pcss partials via `@import` statements.
* - Reference: https://www.npmjs.com/package/postcss-import
* - postcss-preset-env: Sets config to process all features (stage 0 and above)
* - Adds autoprefixer support for css grid
* - Removes any transformations on (don't modify) css custom properties, :focus-visible, and :focus-within
* - Reference: https://www.npmjs.com/package/postcss-preset-env
* - cssnano: minimizes css files ONLY when a production build is run
*/
/**
* Replicates WP-Scripts config for CSS Nano.
*/
const cssNanoConfig = {
preset: [
'default',
{
discardComments: {
removeAll: true,
},
},
],
};
const plugins = [
'postcss-import',
[
'postcss-preset-env',
{
stage: 0,
autoprefixer: { grid: true },
features: {
clamp: false,
'custom-properties': false,
'focus-visible-pseudo-class': false,
'focus-within-pseudo-class': false,
'logical-properties-and-values': false,
},
},
],
];
module.exports = {
plugins:
process.env.NODE_ENV === 'production'
? [ ...plugins, require( 'cssnano' )( cssNanoConfig ) ]
: plugins,
};