Package Exports
- postcss-less
- postcss-less/dist/less-parser
- postcss-less/dist/less-stringify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-less) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
PostCSS LESS Syntax - Work in Progress
This project is not stable and is in development. If you'd like to contribute, please submit a Pull Request.
This module does not compile LESS. It simply parses mixins and variables so that PostCSS plugins can then transform LESS source code alongside CSS.
Use Cases
- lint your LESS code with a plugin such as Stylelint.
- apply PostCSS transformations (such as Autoprefixer) directly to the LESS source code
Usage
LESS Transformations
The main use case of this plugin is to apply PostCSS transformations directly to LESS source code. For example, if you ship a theme written in LESS and need Autoprefixer to add the appropriate vendor prefixes to it.
const syntax = require('postcss-less');
postcss(plugins).process(lessText, { syntax: syntax }).then(function (result) {
result.content // LESS with transformations
});
When you want to lint LESS with a plugin such as Stylelint, you will need to tell postcss-less
to fake LESS-specific syntax.
const syntax = require('postcss-less');
postcss().process(lessText, { syntax: syntax, mixinsAsAtRules: true }).then(function (result) {
result.content // LESS with transformations
});
Inline Comments for PostCSS
This module also enables parsing of single-line comments in CSS source code.
:root {
// Main theme color
--color: red;
}
Note that you don't need a special stringifier to handle the output; the default one will automatically convert single line comments into block comments.
Restrictions
Skipped blocks:
- nested mixins with custom token
nested-mixin
- nested &:extend(); with custom token
nested-extend
Contribution
Please, check our guidelines: CONTRIBUTING.md
Attribution
This module is based on the work of postcss-scss library and includes the LESS
parser efforts of github:gilt/postcss-less