PostCSS Overflow Shorthand
PostCSS Overflow Shorthand lets you use the overflow
shorthand in CSS,
following the CSS Overflow specification.
html {
overflow: hidden auto;
}
/* becomes */
html {
overflow-x: hidden;
overflow-y: auto;
overflow: hidden auto;
}
Usage
Add PostCSS Overflow Shorthand to your build tool:
npm install postcss-overflow-shorthand --save-dev
Node
Use PostCSS Overflow Shorthand to process your CSS:
import postcssOverflowShorthand from 'postcss-overflow-shorthand';
postcssOverflowShorthand.process(YOUR_CSS, , );
PostCSS
Add PostCSS to your build tool:
npm install postcss --save-dev
Use PostCSS Overflow Shorthand as a plugin:
import postcss from 'gulp-postcss';
import postcssOverflowShorthand from 'postcss-overflow-shorthand';
postcss([
postcssOverflowShorthand()
]).process(YOUR_CSS);
Webpack
Add PostCSS Loader to your build tool:
npm install postcss-loader --save-dev
Use PostCSS Overflow Shorthand in your Webpack configuration:
import postcssOverflowShorthand from 'postcss-overflow-shorthand';
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
{ loader: 'postcss-loader', options: {
ident: 'postcss',
plugins: () => [
postcssOverflowShorthand()
]
} }
]
}
]
}
}
Gulp
Add Gulp PostCSS to your build tool:
npm install gulp-postcss --save-dev
Use PostCSS Overflow Shorthand in your Gulpfile:
import postcss from 'gulp-postcss';
import postcssOverflowShorthand from 'postcss-overflow-shorthand';
gulp.task('css', () => gulp.src('./src/*.css').pipe(
postcss([
postcssOverflowShorthand()
])
).pipe(
gulp.dest('.')
));
Grunt
Add Grunt PostCSS to your build tool:
npm install grunt-postcss --save-dev
Use PostCSS Overflow Shorthand in your Gruntfile:
import postcssOverflowShorthand from 'postcss-overflow-shorthand';
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
use: [
postcssOverflowShorthand()
]
},
dist: {
src: '*.css'
}
}
});