All Projects → shellscape → Postcss Less

shellscape / Postcss Less

Licence: mit
PostCSS Syntax for parsing LESS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Postcss Less

postcss-styl
PostCSS parser plugin for converting Stylus syntax to PostCSS AST.
Stars: ✭ 15 (-83.87%)
Mutual labels:  syntax, parse, postcss, postcss-plugin
Static Site Boilerplate
A better workflow for building modern static websites.
Stars: ✭ 1,633 (+1655.91%)
Mutual labels:  stylelint, less, postcss
dva-typescript-antd-starter-kit
A admin dashboard application demo based on antd by typescript and dva
Stars: ✭ 61 (-34.41%)
Mutual labels:  stylelint, less, postcss
Vscode Stylelint
A Visual Studio Code extension to lint CSS/SCSS/Less with stylelint
Stars: ✭ 260 (+179.57%)
Mutual labels:  stylelint, less, postcss
Postcss Icon
PostCSS plugin that adds `css icons` from icon sets
Stars: ✭ 20 (-78.49%)
Mutual labels:  postcss, postcss-plugin
Postcss Register Custom Props
PostCSS plugin that transforms custom property registration in CSS to JS
Stars: ✭ 20 (-78.49%)
Mutual labels:  postcss, postcss-plugin
Postcss Alias
PostCSS plugin that allows you to create aliases for CSS properties
Stars: ✭ 47 (-49.46%)
Mutual labels:  postcss, postcss-plugin
Postcss Nested Props
PostCSS plugin to unwrap nested properties.
Stars: ✭ 58 (-37.63%)
Mutual labels:  postcss, postcss-plugin
Parse Code Context
Parse code context in a single line of javascript, for functions, variable declarations, methods, prototype properties, prototype methods etc.
Stars: ✭ 7 (-92.47%)
Mutual labels:  parser, parse
Postcss Import
PostCSS plugin to inline @import rules content
Stars: ✭ 1,048 (+1026.88%)
Mutual labels:  postcss, postcss-plugin
Webpack Es6 Sass Setup
A basic setup for Webpack with ES6, Babel, Sass and stylelint
Stars: ✭ 63 (-32.26%)
Mutual labels:  stylelint, postcss
Postcss Banner
PostCSS plugin to add text banner and footer to resulting file
Stars: ✭ 13 (-86.02%)
Mutual labels:  postcss, postcss-plugin
Postcss Interpolate
PostCSS plugin for values interpolation between breakpoints.
Stars: ✭ 9 (-90.32%)
Mutual labels:  postcss, postcss-plugin
Algebra Latex
Parse and calculate latex formatted math
Stars: ✭ 20 (-78.49%)
Mutual labels:  parser, parse
Html React Parser
📝 HTML to React parser.
Stars: ✭ 846 (+809.68%)
Mutual labels:  parser, parse
Postcss Triangle
PostCSS plugin to create a triangle.
Stars: ✭ 57 (-38.71%)
Mutual labels:  postcss, postcss-plugin
Bathe
The simplest WordPress starter theme including full setup for Sass, PostCSS, Autoprefixer, stylelint, Webpack, Eslint, imagemin, Browsersync, etc.
Stars: ✭ 65 (-30.11%)
Mutual labels:  stylelint, postcss
Astexplorer.app
https://astexplorer.net with ES Modules support and Hot Reloading
Stars: ✭ 65 (-30.11%)
Mutual labels:  parser, postcss
Parser
Generate a JSON documentation for a SFC Vue component. Contribute: https://gitlab.com/vuedoc/parser#contribute
Stars: ✭ 74 (-20.43%)
Mutual labels:  parser, parse
Postcss Prefix Selector
Prefix all CSS rules with a selector
Stars: ✭ 75 (-19.35%)
Mutual labels:  postcss, postcss-plugin

postcss-less

tests cover size

A PostCSS Syntax for parsing LESS

Note: This module requires Node v6.14.4+. poscss-less is not a LESS compiler. For compiling LESS, please use the official toolset for LESS.

Install

Using npm:

npm install postcss-less --save-dev

Please consider becoming a patron if you find this module useful.

Usage

The most common use of postcss-less is for applying PostCSS transformations directly to LESS source. eg. ia theme written in LESS which uses Autoprefixer to add appropriate vendor prefixes.

const syntax = require('postcss-less');
postcss(plugins)
  .process(lessText, { syntax: syntax })
  .then(function (result) {
    result.content // LESS with transformations
});

LESS Specific Parsing

@import

Parsing of LESS-specific @import statements and options are supported.

@import (option) 'file.less';

The AST will contain an AtRule node with:

  • an import: true property
  • a filename: <String> property containing the imported filename
  • an options: <String> property containing any import options specified

Inline Comments

Parsing of single-line comments in CSS is supported.

:root {
    // Main theme color
    --color: red;
}

The AST will contain a Comment node with an inline: true property.

Mixins

Parsing of LESS mixins is supported.

.my-mixin {
  color: black;
}

The AST will contain an AtRule node with a mixin: true property.

!important

Mixins that declare !important will contain an important: true property on their respective node.

Variables

Parsing of LESS variables is supported.

@link-color: #428bca;

The AST will contain an AtRule node with a variable: true property.

Note: LESS variables are strictly parsed - a colon (:) must immediately follow a variable name.

Stringifying

To process LESS code without PostCSS transformations, custom stringifier should be provided.

const postcss = require('postcss');
const syntax = require('postcss-less');

const less = `
    // inline comment

    .container {
        .mixin-1();
        .mixin-2;
        .mixin-3 (@width: 100px) {
            width: @width;
        }
    }

    .rotation(@deg:5deg){
      .transform(rotate(@deg));
    }
`;

const result = await postcss().process(less, { syntax });

 // will contain the value of `less`
const { content } = result;

Use Cases

  • Lint LESS code with 3rd-party plugins.
  • Apply PostCSS transformations (such as Autoprefixer) directly to the LESS source code

Meta

CONTRIBUTING

LICENSE (MIT)

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].