1. postcss-short-size
Use this in CSS
postcss-short-size
Package: postcss-short-size
Created by: jonathantneal
Last modified: Mon, 19 Feb 2024 21:21:00 GMT
Version: 4.0.0
License: CC0-1.0
Downloads: 24,704
Repository: https://github.com/jonathantneal/postcss-short-size

Install

npm install postcss-short-size
yarn add postcss-short-size

PostCSS Short Size PostCSS

NPM Version
Build Status
Support Chat

PostCSS Short Size lets you use size properties to represent width and
height in CSS, following the 1-to-2 syntax.

.image {
  size: 100px;
}

.video {
  max-size: 400px 300px;
}

/* becomes */

.image {
  width: 100px;
  height: 100px;
}

.video {
  max-width: 400px;
  max-height: 300px;
}

The supported properties are size, min-size, and max-size.

Usage

Add PostCSS Short Size to your project:

 npm install postcss-short-size --save-dev

Use PostCSS Short Size to process your CSS:

 const postcssShortSize = require('postcss-short-size');

postcssShortSize.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

 const postcss = require('postcss');
const postcssShortSize = require('postcss-short-size');

postcss([
  postcssShortSize(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

PostCSS Short Size runs in all Node environments, with special instructions for:

Node PostCSS CLI Webpack Create React App Gulp Grunt

Options

prefix

The prefix option defines a prefix required by properties being transformed.
Wrapping dashes are automatically applied, so that x would transform
-x-margin.

 postcssShortSize({ prefix: 'x' });
.image {
  x-size: 100px;
}

/* becomes */

.image {
  width: 100px;
  height: 100px;
}

skip

The skip option defines the skip token used to ignore portions of the
shorthand.

 postcssShortSize({ skip: '-' });
.image {
  size: - 100px;
}

/* becomes */

.image {
  height: 100px;
}

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin