Registry / devops / rollup-plugin-postcss-webpack-alias-less-loader

rollup-plugin-postcss-webpack-alias-less-loader

JSON →
library1.0.0jsnpmunverified

A custom less loader for rollup-plugin-postcss that enables webpack-style path aliases in Less imports. Version 1.0.0 is the current stable release. It resolves ~ prefixes to node_modules by default and supports user-defined aliasing similar to webpack's resolve.alias. This package is specifically for projects migrating from webpack to Rollup that need alias resolution inside Less files. It integrates with rollup-plugin-postcss and rollup-plugin-alias, and is best used alongside TypeScript via rollup-plugin-typescript2 due to known issues with the original typescript plugin. There are no major updates or maintenance indicators.

npm install rollup-plugin-postcss-webpack-alias-less-loader
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-POST
R
rollup-plugin-postcss-webpack-alias-less-loader
devopsjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rollupPostcssLessLoader
import { rollupPostcssLessLoader } from 'rollup-plugin-postcss-webpack-alias-less-loader'
const rollupPostcssLessLoader = require('rollup-plugin-postcss-webpack-alias-less-loader')
Package itself is CommonJS; both ESM and CJS work. The default export is a function named rollupPostcssLessLoader; named import is correct.
default
import rollupPostcssLessLoader from 'rollup-plugin-postcss-webpack-alias-less-loader'
const { default } = require('rollup-plugin-postcss-webpack-alias-less-loader')
CommonJS default import via require gives the function directly, not an object with default property.
options
import { rollupPostcssLessLoader } from 'rollup-plugin-postcss-webpack-alias-less-loader'; rollupPostcssLessLoader({ nodeModulePath: '...', aliases: {...} })
rollupPostcssLessLoader()
The function accepts an options object with required 'nodeModulePath' and optional 'aliases'.

Configures Rollup to use the custom Less loader with webpack-style aliases inside a postcss plugin.

const postcss = require('rollup-plugin-postcss'); const rollupPostcssLessLoader = require('rollup-plugin-postcss-webpack-alias-less-loader'); const path = require('path'); module.exports = { input: 'src/index.ts', output: { file: 'dist/bundle.js', format: 'esm' }, plugins: [ postcss({ loaders: [ rollupPostcssLessLoader({ nodeModulePath: path.resolve('node_modules'), aliases: { '@myalias': path.resolve('src/aliased-folder'), }, }), ], }), ], };
Debug
Known issues
gotchaThe default `~` resolution points to `node_modules` but can be overridden via `nodeModulePath`.
fix
Explicitly set `nodeModulePath` to avoid resolution errors.
affects: all
gotchaAliases must be absolute paths; relative paths may not resolve correctly.
fix
Use `path.resolve()` to generate absolute aliases.
affects: all
deprecatedPackage has not seen updates since initial release; compatibility with newer Rollup or postcss versions unverified.
fix
Test with your Rollup and postcss versions before using in production.
affects: 1.0.0
gotchaRequires `rollup-plugin-alias` for JS/TS alias resolution; Less alias resolution is separate.
fix
Install and configure `rollup-plugin-alias` with the same aliases if needed for JS files.
affects: all
Errors
Common errors & fixes
Cannot find module 'less'
less is not installed as a dependency of this package; it must be installed separately.
fix
npm install less --save-dev
Error: Cannot resolve '~bootstrap/less/common.less'
The `nodeModulePath` is not set or incorrect, or bootstrap is not installed.
fix
Ensure `nodeModulePath` points to the correct node_modules directory and that bootstrap is installed.
TypeError: rollupPostcssLessLoader is not a function
Incorrect import; the default export is the function.
fix
Use `const rollupPostcssLessLoader = require('rollup-plugin-postcss-webpack-alias-less-loader');` (no destructuring).
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
rollup-plugin-postcssrequiredRequired as the host plugin that runs the loaders
lessrequiredRequired to compile Less files; installed separately
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-postcss-webpack-alias-less-loader — npm install rollup-plugin-postcss-webpack-alias-less-loader · libregistry