grunt-lessvarfile

0.2.2 • Public • Published

grunt-lessvarfile

Create a nice formatted LESS variables-file by collecting variables defined in other LESS-files (modules/components).

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-lessvarfile --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-lessvarfile');

The "lessvarfile" task

Overview

In your project's Gruntfile, add a section named lessvarfile to the data object passed into grunt.initConfig().

grunt.initConfig({
  lessvarfile: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
})

Options

options.alignAt

Type: Int Default value: 40

options.sectionsmap

Type: Object Default value:

{
  'c': 'Colors',
  's': 'Spacing',
  't': 'Typo'
}

options.sectionDelimiter

Type: String Default value: "--"

options.optionalComponentIdentifier

Type: String Default value: "oc__"

options.includeAllComponents

Type: Boolean Default value: true

options.optionalComponentsList

Type: Array Default value: []

Usage Examples

Default Options

grunt.initConfig({
  lessvarfile: {
    options: {},
    files: {
      'your-framework/variables.less': 'your-framework/modules/**/*.less'
    }
  },
})

Custom Options

grunt.initConfig({
  lessvarfile: {
    options: {
      sectionDelimiter: '__',
      alignAt: 1,
      sectionsmap: {
        'c': 'My Crazy Colors',
        's': 'My Spacing',
        't': 'My Typo'
      },
      includeAllComponents: false,
      optionalComponentIdentifier: 'component__',
      optionalComponentsList: ['component__some-component.less']
    },
    files: {
      'your-framework/variables.less': 'your-framework/modules/**/*.less'
    },
  },
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

0.1.0

  • Initial Release

0.1.1

  • Removed "walk" dependency
  • Added delimiter option

0.1.2

  • Renamed Git repository

0.2.0

  • Added some options to mark specific files (components) as optional

0.2.1

  • Bugfixes

0.2.2

  • Bugfixes

Readme

Keywords

Package Sidebar

Install

npm i grunt-lessvarfile

Weekly Downloads

5

Version

0.2.2

License

none

Last publish

Collaborators

  • nsdcss