PostCSS and why?
Benefits
Example
With Sass, we could include a mixin in our files that allows for custom web fonts; thus, we created @font-face tags.
@mixin importfont($font-family, $font-filename, $font-weight : normal, $font-style :normal, $font-stretch : normal) {
@font-face {
font-family: '#{$font-family}';
src: url('#{$font-filename}.eot');
src: url('#{$font-filename}.woff') format('woff'),
url('#{$font-filename}.ttf') format('truetype');
font-weight: $font-weight;
font-style: $font-style;
font-stretch: $font-stretch;
}
}
@include importfont('mission script', 'fonts/mission-script-webfont', 300);
Using the PostCSS FontPath plugin, we can write:
@font-face {
font-family: 'My Font';
font-path: '/path/to/font/file';
font-weight: normal;
font-style: normal;
}
Adding PostCSS To Your Workflow