{"id":18434703,"url":"https://github.com/assemble/assemble-less","last_synced_at":"2025-07-12T04:35:15.163Z","repository":{"id":57184958,"uuid":"8470606","full_name":"assemble/assemble-less","owner":"assemble","description":"Grunt task for compiling LESS to CSS. This task does for less what Assemble does for HTML, making it much easier to modularize and reduce repetition in stylesheets.","archived":false,"fork":false,"pushed_at":"2018-09-24T09:14:47.000Z","size":1648,"stargazers_count":66,"open_issues_count":7,"forks_count":20,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-31T02:12:19.175Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/assemble/assemble/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/assemble.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-28T02:51:21.000Z","updated_at":"2022-03-03T17:15:13.000Z","dependencies_parsed_at":"2022-09-11T07:01:20.279Z","dependency_job_id":null,"html_url":"https://github.com/assemble/assemble-less","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/assemble/assemble-less","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-less","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-less/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-less/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-less/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/assemble","download_url":"https://codeload.github.com/assemble/assemble-less/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assemble%2Fassemble-less/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264939616,"owners_count":23686208,"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-11-06T06:05:00.337Z","updated_at":"2025-07-12T04:35:15.144Z","avatar_url":"https://github.com/assemble.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# assemble-less [![NPM version](https://badge.fury.io/js/assemble-less.png)](http://badge.fury.io/js/assemble-less)  [![Build Status](https://travis-ci.org/assemble/assemble-less.png)](https://travis-ci.org/assemble/assemble-less)\n\n\u003e Compile LESS to CSS. Adds experimental features that extend Less.js for maintaining UI components and themes. From Jon Schlinkert, core team member of Less.js.\n\nThis project is a fork of the popular [grunt-contrib-less](https://github.com/gruntjs/grunt-contrib-less) by the talented [Tyler Kellen](http://goingslowly.com/). Please use that plugin if you require something stable and dependable.\n\n## Getting Started\n\nThis plugin requires Grunt `~0.4.2`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install assemble-less --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('assemble-less');\n```\n\n\n## Less task\n_Run this task with the `grunt less` command._\n\nTask targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.\n\n### Options\n### lessrc\nType: `String`\n\nDefault: null\n\nA convenience option for externalizing task options into a `.lessrc` or `.lessrc.yml` file. If this file is specified, options defined therein will be used.\n\n### globalVars\nType: `Object`\n\nDefault: `undefined`\n\nPrepend variables to source files.\n\n### modifyVars\nType: `Object`\n\nDefault: `undefined`\n\nAppend variables to source files.\n\n### metadata\nType: `String|Array`\n\nDefault: Empty string\n\nPass metadata as context to Lo-Dash templates embedded in LESS files. The name of the files is used as the first path in the template variables, so if you want to use data from `palette.yml`, your templates would look something like: `\u003c%= palette.foo %\u003e`.\n\nData may be formatted in `JSON`, `YAML`. See [this YAML example][1] and [this LESS example][2].\n\n_Note that data passed into `options.metadata` is merged at the task and target levels. You can turn this off by adding `options: {merge: false}`, which then disables merging and allows targets to override any data passed in at the task-level._\n\n### imports\nType: `Object` (each option accepts a `String` or `Array`)\n\nDefault: `null`\n\nPrepend `@import` statements to `src` files using any of the new `@import` directives released after Less.js v1.5.0, `less`, `css`, `inline`, `reference` (`multiple` and `once` probably aren't applicable here, but feel free to use them if you find a use case). See [examples](#usage-examples).\n\n_Any new import directives will be immediately available upon release by Less.js._\n\n### process\nType: `Boolean|Object`\n\nDefault: false\n\nProcess source files as [templates][3] before concatenating.\n\n* `false` - No processing will occur.\n* `true` - Process source files using [grunt.template.process][4] defaults.\n* `options` object - Process source files using [grunt.template.process][4], using the specified options.\n* `function(src, filepath)` - Process source files using the given function, called once for each file. The returned value will be used as source code.\n\n_(Default processing options are explained in the [grunt.template.process][4] documentation)_\n\n### banner\nType: `String`\n\nDefault: Empty string\n\nThis string will be prepended to the beginning of the concatenated output. It is processed using [grunt.template.process][4], using the default options.\n\n_(Default processing options are explained in the [grunt.template.process][4] documentation)_\n\n### stripBanners\nType: `Boolean|Object`\n\nDefault: false\n\nStrip JavaScript banner comments from source files.\n\n* `false` - No comments are stripped.\n* `true` - `/* ... */` block comments are stripped, but _NOT_ `/*! ... */` comments.\n* `options` object:\n  * By default, behaves as if `true` were specified.\n  * `block` - If true, _all_ block comments are stripped.\n  * `line` - If true, any contiguous _leading_ `//` line comments are stripped.\n\n### paths\nType: `String|Array`\n\nDefault: Directory of input file.\n\nSpecifies directories to scan for `@import` directives when parsing. The default value is the directory of the specified source files. In other words, the `paths` option allows you to specify paths for your @import statements in the `less` task as an alternative to specifying a path on every `@import` statement that appears throughout your LESS files. So instead of doing this:\n\n``` css\n@import \"path/to/less/files/mixins.less\";\n```\nyou can do this:\n\n``` css\n@import \"mixins.less\";\n```\n\n##### rootpath\nType: `String`\n\nDefault: `\"\"`\n\nA path to add on to the start of every url resource.\n\n### compress\nType: `Boolean`\n\nDefault: `false`\n\nCompress output by removing some whitespaces.\n\n##### cleancss\nType: `Boolean`\n\nDefault: `false`\n\nCompress output using [clean-css](https://npmjs.org/package/clean-css).\n\n### ieCompat\nType: `Boolean`\n\nDefault: `true`\n\nEnforce the css output is compatible with Internet Explorer 8.\n\nFor example, the [data-uri](https://github.com/cloudhead/less.js/pull/1086) function encodes a file in base64 encoding and embeds it into the generated CSS files as a data-URI. Because Internet Explorer 8 limits `data-uri`s to 32KB, the [ieCompat](https://github.com/cloudhead/less.js/pull/1190) option prevents `less` from exceeding this.\n\n### optimization\nType: `Integer`\n\nDefault: null\n\nSet the parser's optimization level. The lower the number, the less nodes it will create in the tree. This could matter for debugging, or if you want to access the individual nodes in the tree.\n\n### strictImports\nType: `Boolean`\n\nDefault: false\n\nForce evaluation of imports.\n\n### strictMath\nType: `Boolean`\n\nDefault: `false`\n\nWhen enabled, math is required to be in parenthesis.\n\n### strictUnits\nType: `Boolean`\n\nDefault: `false`\n\nWhen enabled, less will validate the units used (e.g. 4px/2px = 2, not 2px and 4em/2px throws an error).\n\n### syncImport\nType: `Boolean`\n\nDefault: `false`\n\nRead @import'ed files synchronously from disk.\n\n### dumpLineNumbers\nType: `String`\n\nDefault: `false`\n\nConfigures -sass-debug-info support.\n\nAccepts following values: `comments`, `mediaquery`, `all`.\n\n### relativeUrls\nType: `Boolean`\n\nDefault: `false`\n\nRewrite urls to be relative. false: do not modify urls.\n\n### customFunctions\nType: `Object`\n\nDefault: none\n\nDefine custom functions to be available within your LESS stylesheets. The function's name must be lowercase and return a primitive type (not an object or array). In the function definition, the first argument is the less object, and subsequent arguments are from the less function call. Values passed to the function are not simple primitive types, rather types defined within less. See the LESS documentation for more information on the available types.\n\n### report\nChoices: `false`|`'min'`|`'gzip'`\n\nDefault: `false`\n\nEither do not report anything, report only minification result, or report minification and gzip results. This is useful to see exactly how well Less is performing, but using `'gzip'` can add 5-10x runtime task execution.\n\nExample ouput using `'gzip'`:\n\n```\nOriginal: 198444 bytes.\nMinified: 101615 bytes.\nGzipped:  20084 bytes.\n```\n\n### sourceMap\nType: `Boolean`\n\nDefault: `false`\n\nEnable source maps.\n\n### sourceMapFilename\nType: `String`\n\nDefault: none\n\nWrite the source map to a separate file with the given filename.\n\n### sourceMapURL\nType: `String`\n\nDefault: none\n\nOverride the default url that points to the sourcemap from the compiled css file.\n\n### sourceMapBasepath\nType: `String`\n\nDefault: none\n\nSets the base path for the less file paths in the source map.\n\n### sourceMapRootpath\nType: `String`\n\nDefault: none\n\nAdds this path onto the less file paths in the source map.\n\n### outputSourceFiles\nType: `Boolean`\n\nDefault: `false`\n\nPuts the less files into the map instead of referencing them.\n\n### version\nType: `String`\n\nDefault: `less` (current release)\n\nSpecify the directory containing the version of Less.js to use for compiling. You may specify a version at the task level or a different version for each target.\n\n```javascript\nless: {\n  options: {\n    version: 'vendor/less'\n  },\n  styles: {\n    files: {\n      'css/style.css': ['src/style.less']\n    }\n  }\n}\n```\nUseful for testing new features included in a beta or alpha release, or for comparing the compiled results from different versions of Less.js.\n\n\n### Usage Examples\n\u003e Basic config for compiling LESS to CSS.\n\n```js\nless: {\n  development: {\n    options: {\n      paths: [\"assets/css\"]\n    },\n    files: {\n      \"path/to/result.css\": \"path/to/source.less\"\n    }\n  },\n  production: {\n    options: {\n      paths: [\"assets/css\"],\n      compress: true\n    },\n    files: {\n      \"path/to/result.css\": \"path/to/source.less\"\n    }\n  }\n}\n```\n\n### lessrc\n\nA `.lessrc` file must contain valid JSON and look something like this:\n\n```json\n{\n  \"compress\": true,\n  \"metadata\": \"src/*.{json,yml}\",\n  \"paths\": [\"vendor/bootstrap/less\"]\n}\n```\n\nA `.lessrc.yml` must contain valid YAML and look something like this:\n\n```yaml\ncompress: true\npaths:\n- vendor/bootstrap/less\n```\n\n### Import directives\n\n\u003e Prepend `@import` statements to `src` files using any of the new `@import` directives released after Less.js v1.5.0.\n\nOptions are:\n\n* `reference`: use a less file but do not output it\n* `inline`: include the source file in the output but do not process as less\n* `less`: treat the file as a less file, no matter what the file extension\n* `css`: treat the file as a css file, no matter what the file extension\n\n```javascript\nless: {\n  options: {\n    paths: 'vendor/bootstrap/less',\n    imports: {\n      reference: ['variables.less', 'mixins.less'],\n      inline: ['normalize.css'],\n      less: ['normalize.css'],\n      css: ['foo.css', 'bar.css']\n    }\n  },\n  files: {}\n}\n```\n\n### Compile individual bootstrap components\n\n\u003e Use import directives to compile each [Bootstrap's](https://github.com/twbs/bootstrap) LESS components separately.\n\nUsing the `imports: {}` option and the \"files array format\" enables us to compile each Bootstrap LESS component without having to add `@import \"variables.less\";` and `@import \"mixins.less\";` to\nevery file.\n\n```javascript\nless: {\n  options: {\n    paths: 'vendor/bootstrap/less',\n    imports: {\n      reference: ['variables.less', 'mixins.less'],\n    }\n  },\n  components: {\n    files: [\n      { expand: true, cwd: 'vendor/bootstrap/less', src: '*.less', dest: 'assets/css/', ext: '.css' }\n    ]\n  }\n}\n```\n\n### Pass metadata to Lo-Dash templates\n\nUse the `metadata` option to pass context to Lo-Dash templates before compiling. For example, let's say you have a config like this:\n\n```javascript\nless: {\n  options: {\n    metadata: 'src/*.{json,yml}'\n  },\n  styles: {\n    files: {\n      'css/style.css': ['src/style.less']\n    }\n  }\n}\n```\n\nand a data file, `palette.yml`, with some variables defined:\n\n```yaml\n## palette.yml\ninfo:    '#000'\nwarning: '#111'\ndanger:  '#222'\nsuccess: '#333'\n```\n\nThen in our LESS file:\n\n```scss\n// Use as values to variables\n@palette-info:    \u003c%= palette.info %\u003e;\n@palette-warning: \u003c%= palette.warning %\u003e;\n\n.swatch-info {\n  background: @palette-info;\n}\n.swatch-warning {\n  background: @palette-warning;\n}\n\n// or directly as variables\n.swatch-danger {\n  background: \u003c%= palette.danger %\u003e;\n}\n.swatch-success {\n  background: \u003c%= palette.success %\u003e;\n}\n```\n\n\n\n## Release History\n\n * 2014-01-01   v0.7.0   Update to use the Less.js v1.6.0 API for `banner`, `globalVars` and `modifyVars`.\n * 2013-12-18   v0.6.0   Adds `globalVars` and `modifyVars` options. See readme and Gruntfile for examples. Support `sourceMapURL` Support `outputSourceFiles` Support `sourceMapFilename`, `sourceMapBasepath` and `sourceMapRootpath` Upgrade to LESS 1.5 Support `strictUnits` option Support sourceMap option Add `customFunctions` option for defining custom functions within LESS Output the source file name on error yuicompress option now cleancss (Less changed underlying dependency)\n * 2013-07-30   v0.5.0   Completely refactored the plugin based on grunt-contrib-less. Add examples for all features to Gruntfile. Removed the concat feature. You can now use `.lessrc` or `.lessrc.yml` for externalizing task options. New `stripBanners` option\n * 2013-06-13   v0.4.7   Cleaned up a lot of the Gruntfile. Examples are more clear. New `import` option for prepending import statements to LESS files before compiling. New `banner` option for adding banners to generated CSS files.\n * 2013-03-17   v0.3.0   New option to specify the version of less.js to use for compiling to CSS.\n * 2013-03-14   v0.2.3   New options from Less.js 1.4.0\n * 2013-02-27   v0.1.0   First commit.\n\n\n## Authors\nThis project is a fork of the popular [grunt-contrib-less](https://github.com/gruntjs/grunt-contrib-less) by [Tyler Kellen](http://goingslowly.com/). Please use that plugin if you require something stable and dependable.\n\nThis fork is maintained by:\n\n**Jon Schlinkert**\n\n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n**Brian Woodward**\n\n+ [github/doowb](https://github.com/doowb)\n+ [twitter/doowb](http://twitter.com/jonschlinkert)\n\n\n## License\nCopyright (c) 2014 Jon Schlinkert, contributors.\nReleased under the MIT license\n\n***\n\n_This file was generated by [grunt-readme](https://github.com/assemble/grunt-readme) on Wednesday, January 1, 2014._\n\n[grunt]: http://gruntjs.com/\n[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md\n[package.json]: https://npmjs.org/doc/json.html\n\n\n[1]: https://github.com/assemble/assemble-less/blob/master/test/fixtures/data/palette.yml\n[2]: https://github.com/assemble/assemble-less/blob/master/test/fixtures/templates-palette.less\n[3]: http://gruntjs.com/api/grunt.template\n[4]: http://gruntjs.com/api/grunt.template#grunt.template.process","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemble%2Fassemble-less","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fassemble%2Fassemble-less","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemble%2Fassemble-less/lists"}