{"id":22169,"library":"rollup-plugin-postcss-webpack-alias-less-loader","title":"rollup-plugin-postcss-webpack-alias-less-loader","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/fieldju/rollup-plugin-postcss-webpack-alias-less-loader","tags":["javascript"],"install":[{"cmd":"npm install rollup-plugin-postcss-webpack-alias-less-loader","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-postcss-webpack-alias-less-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-postcss-webpack-alias-less-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as the host plugin that runs the loaders","package":"rollup-plugin-postcss","optional":false},{"reason":"Required to compile Less files; installed separately","package":"less","optional":false}],"imports":[{"note":"Package itself is CommonJS; both ESM and CJS work. The default export is a function named rollupPostcssLessLoader; named import is correct.","wrong":"const rollupPostcssLessLoader = require('rollup-plugin-postcss-webpack-alias-less-loader')","symbol":"rollupPostcssLessLoader","correct":"import { rollupPostcssLessLoader } from 'rollup-plugin-postcss-webpack-alias-less-loader'"},{"note":"CommonJS default import via require gives the function directly, not an object with default property.","wrong":"const { default } = require('rollup-plugin-postcss-webpack-alias-less-loader')","symbol":"default","correct":"import rollupPostcssLessLoader from 'rollup-plugin-postcss-webpack-alias-less-loader'"},{"note":"The function accepts an options object with required 'nodeModulePath' and optional 'aliases'.","wrong":"rollupPostcssLessLoader()","symbol":"options","correct":"import { rollupPostcssLessLoader } from 'rollup-plugin-postcss-webpack-alias-less-loader'; rollupPostcssLessLoader({ nodeModulePath: '...', aliases: {...} })"}],"quickstart":{"code":"const postcss = require('rollup-plugin-postcss');\nconst rollupPostcssLessLoader = require('rollup-plugin-postcss-webpack-alias-less-loader');\nconst path = require('path');\n\nmodule.exports = {\n  input: 'src/index.ts',\n  output: { file: 'dist/bundle.js', format: 'esm' },\n  plugins: [\n    postcss({\n      loaders: [\n        rollupPostcssLessLoader({\n          nodeModulePath: path.resolve('node_modules'),\n          aliases: {\n            '@myalias': path.resolve('src/aliased-folder'),\n          },\n        }),\n      ],\n    }),\n  ],\n};","lang":"javascript","description":"Configures Rollup to use the custom Less loader with webpack-style aliases inside a postcss plugin."},"warnings":[{"fix":"Explicitly set `nodeModulePath` to avoid resolution errors.","message":"The default `~` resolution points to `node_modules` but can be overridden via `nodeModulePath`.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `path.resolve()` to generate absolute aliases.","message":"Aliases must be absolute paths; relative paths may not resolve correctly.","severity":"gotcha","affected_versions":"all"},{"fix":"Test with your Rollup and postcss versions before using in production.","message":"Package has not seen updates since initial release; compatibility with newer Rollup or postcss versions unverified.","severity":"deprecated","affected_versions":"1.0.0"},{"fix":"Install and configure `rollup-plugin-alias` with the same aliases if needed for JS files.","message":"Requires `rollup-plugin-alias` for JS/TS alias resolution; Less alias resolution is separate.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install less --save-dev","cause":"less is not installed as a dependency of this package; it must be installed separately.","error":"Cannot find module 'less'"},{"fix":"Ensure `nodeModulePath` points to the correct node_modules directory and that bootstrap is installed.","cause":"The `nodeModulePath` is not set or incorrect, or bootstrap is not installed.","error":"Error: Cannot resolve '~bootstrap/less/common.less'"},{"fix":"Use `const rollupPostcssLessLoader = require('rollup-plugin-postcss-webpack-alias-less-loader');` (no destructuring).","cause":"Incorrect import; the default export is the function.","error":"TypeError: rollupPostcssLessLoader is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}