-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostcss.config.js
47 lines (45 loc) · 1.46 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
/**
* @typedef {Object} CSSNanoOptions
* @property {boolean} discardComments.removeAll - Remove all comments
* @property {boolean} colormin - Minify colors
* @property {boolean} reduceIdents - Control class/ID minification
* @property {boolean} mergeLonghand - Merge longhand properties
* @property {boolean} cssDeclarationSorter - Sort CSS declarations
* @property {boolean} minifyFontValues - Minify font declarations
* @property {boolean} svgo - Control SVG optimization
*/
/**
* @typedef {Object} PostCSSContext
* @property {'production' | 'development'} env - The current environment
*/
/**
* PostCSS configuration with environment-specific optimizations
* @param {PostCSSContext} ctx - PostCSS context object
* @returns {import('postcss').ProcessOptions} PostCSS configuration object
*/
export default (ctx) => ({
plugins: {
tailwindcss: {},
autoprefixer: {},
...(ctx.env === 'production'
? {
cssnano: {
preset: [
'advanced',
{
discardComments: {
removeAll: true,
},
colormin: true,
reduceIdents: false, // Prevents breaking animations
mergeLonghand: true,
cssDeclarationSorter: true,
minifyFontValues: true,
svgo: false, // Disable SVG optimization as it can cause issues
},
],
},
}
: {}),
},
});