Андрей Ситник, Злые марсиане
a {<%= include clickable %>color: <%= $link-color %>;}
gulp.task('css', () => {
let postcss = require('gulp-postcss');
return gulp.src('src/*.css')
.pipe( postcss([ plugin1, plugin2 ]) )
.pipe( gulp.desc('build/') );
});Выйти за пределы старых препроцессоров:
postcss([
require('autoprefixer')({
browsers: 'last 2 version'
}),
require('postcss-cssnext'),
require('precss')
]).icon {
top: center;
}@use postcss-center;
.icon {
top: center;
}@use: lost, postcss-center, postcss-circleprecss: возможности Sasscssnext: полифилы для «CSS 4»oldie: поддержка IE 8var moment = require('moment');logo/
logo.jslogo.csslogo.svgheader/
header.jsheader.csslogo.css
header.css
.name {
color: black;
}
.name {
color: gray;
}import styles from './logo.css';
class Logo extends React.Component {
render() {
return <div className={ styles.name }>We</div>;
}
}CSS Modules:
БЭМ
<Header>
color: white
<Logo>
background: white
</Logo>
</Header>* {
box-sizing: border-box;
}
div {
margin-top: 10px;
}.logo {
color: black;
}
.logo--big {
width: 200px;
}
.logo {
all: initial;
color: black;
}
.logo--big {
width: 200px;
}.logo {
all: initial;
}
.logo {
color: black;
background: white;
box-sizing: content-box;
line-height: normal;
text-shadow: none;
vertical-align: baseline;
white-space: normal;postcss-autoresetpostcss-initialРазмеры картинок:
.icon {
width: width('logo.png');
height: height('logo.png');
background: inline('logo.png');
}@custom-media --phones (width <= 700px);
@custom-media --hidpi (resolution >= 2dppx);
@media (--phones) { }
@media (--phones) and (--hidpi) { }:fullscreen { }
:-webkit-full-screen { }
:-moz-full-screen { }
:-ms-fullscreen { }
:fullscreen { }body {
font-family: Alice;
}
@font-face {
font-family: Alice;
font-style: normal;
font-weight: 400;
src: local("Alice"),
url("//fonts.gstatic.com/….woff")
format("woff");
}
body {
font-family: Alice;
}.popup {
background:
rgba(153, 221, 153, 0.8);
}
.popup {
background: #99dd99; /* IE 8 */
background:
rgba(153, 221, 153, 0.8);
}.icon {
background: url(logo.svg);
background-size: 20px 20px;
}
.icon {
background: url(logo.svg);
background-size: 20px 20px;
}
.no-svg.icon {
background: url(logo-20x20.png);
}.icon {
background: svg('logo.svg', '[fill]: #c00');
}Более 85 правил:
"rules": {
"indentation": 2,
"number-leading-zero": 2,
"color-no-invalid-hex": 2
}main.css:13:3: Pointer events not supported by: IE (9,10)
.arrow {@svg {polygon {fill: green;points: 50,100 0,0 0,100;}}}
Старый проект:
Новый проект:
.pipe( sass() ).pipe( postcss([...plugins]) )
.pipe( postcss([precss,...plugins]) )
postcss-use