Performance: Configuration file structure
This affects the build time and final CSS bundle size by controlling which styles are generated and included.
Jump into concepts and practice - no test required
module.exports = {
theme: {
extend: {
colors: {
primary: '#1da1f2',
secondary: '#14171a'
}
}
},
variants: {},
plugins: []
}module.exports = {
theme: {
extend: {
colors: {
primary: '#1da1f2',
secondary: '#14171a',
accent: '#657786',
extra1: '#aab8c2',
extra2: '#e1e8ed',
extra3: '#f5f8fa',
// many unused colors
}
}
},
variants: {},
plugins: []
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large config with many unused colors | No direct DOM impact | No reflows | High paint cost due to large CSS | [X] Bad |
| Minimal config with only needed colors | No direct DOM impact | No reflows | Low paint cost with small CSS | [OK] Good |
content array in the Tailwind configuration file?contentcontent array lists files where Tailwind looks for class names to generate styles.theme.extend, not content.tailwind.config.js?theme.extend.colors.tailwind.config.js snippet, what will be the background color class for the custom color?module.exports = {
theme: {
extend: {
colors: {
brand: '#1a202c'
}
}
}
}bg-[colorName] for backgrounds.brand, so background class is bg-brand.module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
primary: '#ff0000'
},
extend: {
fontFamily: {
sans: ['Arial', 'sans-serif']
}
}
}
}heading and a custom color accent without removing Tailwind's defaults. Which config structure correctly achieves this?theme.extend.module.exports = {
theme: {
extend: {
fontFamily: { heading: ['Georgia', 'serif'] },
colors: { accent: '#ff6600' }
}
}
} correctly puts both fontFamily and colors inside extend under theme.