npm install postcss-less --save-dev
const syntax = require ( 'postcss-less' ) ;
postcss ( plugins )
. process ( lessText , { syntax : syntax } )
. then ( function ( result ) {
result . content // LESS with transformations
} ) ;
@import (option) ' file.less ' ;
-
an import: true property -
a filename: <String> property containing the imported filename -
an options: <String> property containing any import options specified
:root { // Main theme color
--color : red ; }
.my-mixin { color : black ; }
@link-color : #428bca ;
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 ;
-
Lint LESS code with 3rd-party plugins. -
Apply PostCSS transformations (such as Autoprefixer ) directly to the LESS source code