This plugin provides less imports from node_modules
, just like less/less-plugin-npm-import and webpack's less-loader do.
Install with npm (or yarn):
$ npm install @thomann/less-plugin-nodemodules-import
Register with your less instance:
const LessPluginNodeModulesImport = require('@thomann/less-plugin-nodemodules-import');
less.render(anyFile, {plugins: [new LessPluginNodeModulesImport(opts)]});
$ lessc --plugin=@thomann/less-plugin-nodemodules-import <less-file>
To define options with command line usage, pass a JSON object string with the parameters as less plugin option:
$ lessc --plugin=@thomann/less-plugin-nodemodules-import={"mainFile":"main.less"}
Note that the parameters have to be valid JSON.
OptionKey | Value Type | Default | Description |
---|---|---|---|
importPaths |
array | values from require.module.paths | The paths to find imports in |
mainFile |
string | index.less | Which file to load if the import is a directory |
encoding |
string | utf-8 | Encoding for reading imported files |
Directories in importPaths
have to be absolute or relative to the current working directory.