All Projects → Jeff2Ma → postcss-lazyimagecss

Jeff2Ma / postcss-lazyimagecss

Licence: MIT license
A PostCSS plugin that generates images's CSS width & height properties automatically.

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to postcss-lazyimagecss

postcss-input-style
PostCSS plugin that adds new pseudo-elements for easily styling the inner elements of inputs
Stars: ✭ 16 (-57.89%)
Mutual labels:  postcss, postcss-plugin
postcss-gtk
Processes GTK+ CSS into browser CSS
Stars: ✭ 23 (-39.47%)
Mutual labels:  postcss, postcss-plugin
postcss-center
PostCSS plugin to center elements.
Stars: ✭ 44 (+15.79%)
Mutual labels:  postcss, postcss-plugin
postcss-font-pack
PostCSS plugin to simplify font declarations by validating only configured font packs are used and adding fallbacks.
Stars: ✭ 18 (-52.63%)
Mutual labels:  postcss, postcss-plugin
postcss-rename
Replace class names based on a customizable renaming scheme.
Stars: ✭ 77 (+102.63%)
Mutual labels:  postcss, postcss-plugin
postcss-trash-killer
It is a postcss plugin which wil be remove all unused css
Stars: ✭ 20 (-47.37%)
Mutual labels:  postcss, postcss-plugin
postcss-prefixwrap
A PostCSS plugin that is used to wrap css styles with a css selector to constrain their affect on parent elements in a page.
Stars: ✭ 54 (+42.11%)
Mutual labels:  postcss, postcss-plugin
Postcss Aspect Ratio Mini
A PostCSS plugin to fix an element's dimensions to an aspect ratio
Stars: ✭ 123 (+223.68%)
Mutual labels:  postcss, postcss-plugin
postcss-critical-css
PostCSS plugin to define and output critical CSS using custom atRules, and/or custom CSS properties. Critical CSS may be output to one or more files, as defined within the plugin options or within the CSS.
Stars: ✭ 84 (+121.05%)
Mutual labels:  postcss, postcss-plugin
postcss-styl
PostCSS parser plugin for converting Stylus syntax to PostCSS AST.
Stars: ✭ 15 (-60.53%)
Mutual labels:  postcss, postcss-plugin
Postcss Spiffing
PostCSS plugin to use British English
Stars: ✭ 158 (+315.79%)
Mutual labels:  postcss, postcss-plugin
postcss-windicss
PostCSS integrations for Windi CSS
Stars: ✭ 33 (-13.16%)
Mutual labels:  postcss, postcss-plugin
Postcss Rtl
PostCSS plugin for RTL-adaptivity
Stars: ✭ 143 (+276.32%)
Mutual labels:  postcss, postcss-plugin
postcss-clearfix
PostCSS plugin that adds a 'fix' argument to the 'clear' property
Stars: ✭ 47 (+23.68%)
Mutual labels:  postcss, postcss-plugin
Postcss Viewport Height Correction
PostCSS plugin to solve the popular problem when 100vh doesn’t fit the mobile browser screen.
Stars: ✭ 137 (+260.53%)
Mutual labels:  postcss, postcss-plugin
postcss-import-url
PostCSS plugin inlines remote files.
Stars: ✭ 47 (+23.68%)
Mutual labels:  postcss, postcss-plugin
Postcss Plugins
The "officially unofficial" consolidated list of PostCSS plugins in a ready-to-use package
Stars: ✭ 107 (+181.58%)
Mutual labels:  postcss, postcss-plugin
Container Query
A PostCSS plugin and Javascript runtime combination, which allows you to write container queries in your CSS the same way you would write media queries.
Stars: ✭ 119 (+213.16%)
Mutual labels:  postcss, postcss-plugin
postcss-inline-media
Media queries shortcut, built on PostCSS, example: font-size: 20px @1200 18px @480 16px;
Stars: ✭ 47 (+23.68%)
Mutual labels:  postcss, postcss-plugin
postcss
No description or website provided.
Stars: ✭ 59 (+55.26%)
Mutual labels:  postcss, postcss-plugin

postcss-lazyimagecss

Greenkeeper badge

Build Status npm version

A PostCSS plugin that generates images's CSS width & height properties from stylesheets automatically.

Another lazy way to write CSS, feel free to use it :)

Based on gulp-lazyimagecss. Thanks to hzlzh and littledu.

/* Input */
.icon-close {
	background-image: url(../slice/icon-close.png); //icon-close.png - 16x16
}

.icon-new {
	background-image: url(../slice/[email protected]); //icon-new@2x.png - 16x16
}
	
/* Output */
.icon-close {
	background-image: url(../slice/icon-close.png);
	width: 16px;
	height: 16px;
}

.icon-new {
	background-image: url(../slice/[email protected]);
	width: 8px;
	height: 8px;
	background-size: 8px 8px;
}

Features

  • Support jpg/jpeg/png/gif/bmp/svg file type.

  • Support retina image (file name should like [email protected]).

  • Both background-image: url() and background: url() can be detected successfully.

  • CSS property generating will be ignored if any of those width / height / background-size already set.

Installation

Install with npm:

npm install postcss-lazyimagecss --save-dev

Or install width yarn:

yarn add postcss-lazyimagecss --dev

Usage

Work with Gulp

Example:

var gulp = require('gulp');
var postcss = require('gulp-postcss');
var lazyimagecss = require('postcss-lazyimagecss');

gulp.task('css', function () {
	return gulp.src('./src/css/*.css')
	    .pipe(another-plugin())
		.pipe(postcss([lazyimagecss({
			imagePath: ['../img','../slice']
		})]))
		.pipe(gulp.dest('./dist/css'));
});

Work with Gulp & gulp-sourcemaps

Example:

var gulp = require('gulp');
var postcss = require('gulp-postcss');
var lazyimagecss = require('postcss-lazyimagecss');
var sourcemaps = require('gulp-sourcemaps');

gulp.task('css', function () {
	return gulp.src('./src/css/*.css')
		.pipe(sourcemaps.init())
		.pipe(another-plugin())
		.pipe(postcss([lazyimagecss({
			imagePath: ['../img','../slice']
		})]))
		.pipe(sourcemaps.write("."))
		.pipe(gulp.dest('./dist'));
});

Options

  • imagePath Set image path to be worked (e.g. ['../slice','../img'])

  • width Whether output width properties in CSS ( default: true )

  • height Whether output height properties in CSS ( default: true )

  • backgroundSize Whether output background-size properties in CSS ( default: true )

Contributing

Issues and Pull requests are welcome.

$ git clone https://github.com/Jeff2Ma/postcss-lazyimagecss
$ cd postcss-lazyimagecss
$ npm i
$ gulp
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].