generated from KevinBatdorf/gutenberg-rust-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
postcss.config.js
35 lines (34 loc) · 1.25 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
const tailwind = require('./tailwind.config');
module.exports = ({ mode }) => ({
ident: 'postcss',
sourceMap: mode !== 'production',
plugins: [
require('postcss-import'),
require('tailwindcss/nesting'),
require('tailwindcss')({
...tailwind,
// Scope the editor css separately from the frontend css.
content: ['./src/**/*.{ts,tsx}'],
important: tailwind.important + '-editor',
}),
(css) =>
css.walkRules((rule) => {
// Removes top level TW styles like *::before {}
rule.selector.startsWith('*') && rule.remove();
}),
// See: https://github.com/WordPress/gutenberg/blob/trunk/packages/postcss-plugins-preset/lib/index.js
require('autoprefixer')({ grid: true }),
mode === 'production' &&
// See: https://github.com/WordPress/gutenberg/blob/trunk/packages/scripts/config/webpack.config.js#L68
require('cssnano')({
preset: [
'default',
{
discardComments: {
removeAll: true,
},
},
],
}),
],
});