Install
npm i -D postcss-less-loader
Usage
Configuration
postcss.config.js
moduleexports = plugins:
webpack.config.js
moduleexports = module: rules: test: /\.s[ca]ss$/ use: 'style-loader' 'css-loader' 'postcss-less-loader'
webpack.config.js
(recommended)
moduleexports = module: rules: test: /\.css$/ use: 'style-loader' loader: 'css-loader' options: alias: "@test": "/home/test" 'postcss-less-loader'
Options
Name | Type | Default | Description |
---|---|---|---|
config |
{Object} |
undefined |
Set postcss.config.js config path && ctx |
plugins |
{Array\|Function} |
[] |
Set PostCSS Plugins |
sourceMap |
{String\|Boolean} |
false |
Enable Source Maps |
alias |
{Object} |
undefined |
Set import alias |
Plugins
webpack.config.js
loader: 'postcss-less-loader' options: ident: 'postcss' root: loaderresourcePath
alias
webpack.config.js
test: /\.s[ca]ss$/ use: 'style-loader' 'css-loader' loader: 'postcss-less-loader' options: alias: "@test": "/home/test"
⚠️ webpack requires an identifier (
ident
) inoptions
when{Function}/require
is used (Complex Options). Theident
can be freely named as long as it is unique. It's recommended to name it (ident: 'postcss'
)
Examples
Autoprefixing
webpack.config.js
test: /\.s[ca]ss$/ use: 'style-loader' 'css-loader' loader: 'postcss-less-loader' options: plugins: ...options ...