const postcssJs = require ( 'postcss-js' )
const autoprefixer = require ( 'autoprefixer' )
const prefixer = postcssJs . sync ( [ autoprefixer ] )
const style = prefixer ( {
userSelect : 'none'
} )
style //=> {
// WebkitUserSelect: 'none',
// MozUserSelect: 'none',
// msUserSelect: 'none',
// userSelect: 'none'
// }
const postcss = require ( 'postcss' )
const postcssJs = require ( 'postcss-js' )
const style = {
top : ten ,
'&:hover' : {
top : five
}
} ;
postcss ( ) . process ( style , { parser : postcssJs } ) . then ( ( result ) => {
result . css //=> top: 10px;
// &:hover { top: 5px; }
} )
const postcss = require ( 'postcss' )
const postcssJs = require ( 'postcss-js' )
const css = '--text-color: #DD3A0A; @ media screen { z-index: 1; color: var(--text-color) }'
const root = postcss . parse ( css )
postcssJs . objectify ( root ) //=> {
// '--text-color': '#DD3A0A',
// '@media screen': {
// zIndex: '1',
// color: 'var(--text-color)'
// }
// }
{
'@media screen' : {
'&:hover' : {
top : ten
}
}
}
postcss ( ) . process ( obj , { parser : postcssJs } )
loaders: [
{
test : / \.json$ / ,
loader : "json-loader"
}
]