{"id":16440326,"url":"https://github.com/constgen/neutrino-middleware-less-loader","last_synced_at":"2025-07-31T08:41:57.309Z","repository":{"id":143896178,"uuid":"103581160","full_name":"constgen/neutrino-middleware-less-loader","owner":"constgen","description":"Less loader for Neutrino","archived":false,"fork":false,"pushed_at":"2021-03-16T23:00:53.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T03:06:23.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/constgen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-14T20:58:24.000Z","updated_at":"2021-03-16T23:00:52.000Z","dependencies_parsed_at":"2023-06-26T01:57:06.426Z","dependency_job_id":null,"html_url":"https://github.com/constgen/neutrino-middleware-less-loader","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constgen%2Fneutrino-middleware-less-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constgen%2Fneutrino-middleware-less-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constgen%2Fneutrino-middleware-less-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/constgen%2Fneutrino-middleware-less-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/constgen","download_url":"https://codeload.github.com/constgen/neutrino-middleware-less-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240766672,"owners_count":19854114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T09:11:50.052Z","updated_at":"2025-02-25T23:45:06.326Z","avatar_url":"https://github.com/constgen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Neutrino Less loader middleware\n\n[![npm](https://img.shields.io/npm/v/neutrino-middleware-less-loader.svg)](https://www.npmjs.com/package/neutrino-middleware-less-loader)\n[![npm](https://img.shields.io/npm/dt/neutrino-middleware-less-loader.svg)](https://www.npmjs.com/package/neutrino-middleware-less-loader)\n\n`neutrino-middleware-less-loader` is a [Neutrino](https://neutrino.js.org) middleware for compiling styles with [Less](http://lesscss.org/). This middleware only transforms Less to CSS. It is recommended to have `@neutrinojs/style-loader` (or its substitution) in the configuration to be able to compile Less styles to JavaScript modules.\n\n## Requirements\n\n* Node.js v10.13+\n* Neutrino v9\n\n## Installation\n\n`neutrino-middleware-less-loader` can be installed from NPM. You should install it to `\"dependencies\"` (--save) or `\"devDependncies\"` (--save-dev) depending on your goal.\n\n```bash\nnpm install --save-dev neutrino-middleware-less-loader\n```\n\n## Usage\n\n`neutrino-middleware-less-loader` can be consumed from the Neutrino API, middleware, or presets.\n\n### In preset\n\nRequire this package and plug it into Neutrino. The following shows how you can pass an options object to the middleware, showing the defaults:\n\n```js\nlet lessLoader = require('neutrino-middleware-less-loader')\n\nneutrino.use(lessLoader({\n   include: ['src', 'tests'],\n   exclude: [],\n   less   : {\n      insecure   : true,\n      paths      : [],\n      rewriteUrls: 'all',\n      math       : 'always',\n      strictUnits: false,\n      globalVars : {},\n      modifyVars : {},\n      urlArgs    : '',\n      plugins    : []\n   }\n}))\n```\n\n* `include`: optional array of paths to include in the compilation. Maps to Webpack's rule.include.\n* `exclude`: optional array of paths to exclude from the compilation. Maps to Webpack's rule.include.\n* `less`: optional [Less options](http://lesscss.org/3.x/usage/#less-options) config that is passed to the loader.\n\nIt is recommended to call this middleware after the `neutrino.config.module.rule('style')` initialization to avoid unexpected overriding. More information about usage of Neutrino middlewares can be found in the [documentation](https://neutrino.js.org/middleware).\n\n### In **neutrinorc**\n\nThe middleware also may be used together with another presets in Neutrino rc-file, e.g.:\n\n**.neutrinorc.js**\n\n```js\nlet web        = require('@neutrino/web')\nlet lessLoader = require('neutrino-middleware-less-loader')\n\nmodule.exports = {\n   use: [\n      web(),\n      lessLoader()\n   ]\n}\n```\n\n### Imports paths\n\nThe loader can resolve paths in one of two modes: Less or Webpack.\n\nWebpack's resolver is used by default. To use its advantages to look up the `modules` you need to prepend `~` to the path:\n\n```css\n@import \"~bootstrap/less/bootstrap\";\n```\n\nOtherwise the path will be determined as a relative URL, `@import \"file\"` is the same as `@import \"./file\"`\n\nIf you specify the `paths` option, the Webpack's resolver will not be used. Modules, that can't be resolved in the local folder, will be searched in the given `paths`. This is Less' default behavior. `paths` should be an array with absolute paths:\n\n```js\nlet lessLoader = require('neutrino-middleware-less-loader')\n\nneutrino.use(lessLoader({\n   less: {\n      paths: [\n         path.resolve(__dirname, 'node_modules')\n      ]\n   }\n}))\n```\n\n### Importing variables from JS\n\nLESS files can import variables from JS modules. Example:\n\n**vars.js**\n\n```js\nmodule.exports = {\n   'default-color': 'yellow',\n   'border'       : '2px solid red'\n}\n```\n\n**main.less**\n\n```less\nrequire('./vars.js');\n\n@import \"./other.less\";\n\n.box:extend(.darkgreen) {\n  color: @default-color;\n  border: @border;\n  width: 200px;\n  height: 200px;\n}\n```\n\nIt is recommended to `require` all JS modules before any `@import` rules.\n\n### Plugins\n\nIn order to use LESS plugins, simply set the `plugins` option:\n\n```js\nlet CleanCSSPlugin = require('less-plugin-clean-css')\n\nneutrino.use(lessLoader({\n   less: {\n      plugins: [\n         new CleanCSSPlugin({ advanced: true })\n      ]\n   }\n}))\n```\n\n## Rules\n\nThis is a list of rules that are used by `neutrino-middleware-less-loader`:\n\n* `less`: Compiles Less styles to CSS styles. Contains two loaders named: `less` and `less-var`.\n* `style`: Only necessary file extension added. CSS loader should be provided to correctly compile styles to JavaScript.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconstgen%2Fneutrino-middleware-less-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconstgen%2Fneutrino-middleware-less-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconstgen%2Fneutrino-middleware-less-loader/lists"}