Create LESS import files automatically
npm install grunt-lessimportfileThis Plugin lets your create a LESS import file automatically by running threw specified folders. This is useful if you are at the beginning of the development-process and want easily change the structure or names of your files and folders without having to care for the import statements in your "master" less file.
~0.4.1If 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:
``shell`
npm install grunt-lessimportfile --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-lessimportfile');
to the data object passed into grunt.initConfig().`js
grunt.initConfig({
lessimportfile: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
`$3
#### options.asReferenceIdentifier
asReferenceIdentifier
Type:
String
Default value: "__"Import the prefixed file as a reference. It will create an import-statement like this:
@import (reference) "__file#### options.asReference
Type:
Boolean
Default value: falseImport the specified files as a reference. It will create an import-statement like this:
@import (reference) "file.less"#### options.copyExisting
Type:
Boolean
Default value: falseKeep the content of the specified target file.
#### options.optionalComponentIdentifier
Type:
String
Default value: "oc__"#### options.includeAllComponents
Type:
Boolean
Default value: true#### options.optionalComponentsList
Type:
Array
Default value: []$3
#### Default Options
In this example, the default options are used.
`js
grunt.initConfig({
lessimportfile: {
options: {},
files: {
'your-framework/master.less': ['your-framework/modules/*/.less', 'your-framework/variables.less']
},
},
})
`#### Custom Options
In this example, custom options are used.
`js
grunt.initConfig({
lessimportfile: {
setup: {
options: {
asReferenceIdentifier: '_r_'
},
files: {
'your-framework/master.less': ['your-framework/base/*/.less']
},
},
framework: {
options: {
asReference: true,
copyExisting: true
},
files: {
'your-framework/master.less': ['your-framework/abstract-modules/*/.less'],
},
},
components: {
options: {
copyExisting: true,
includeAllComponents: false,
optionalComponentIdentifier: 'comp__',
optionalComponentsList: ['comp__flyout-nav.less', 'comp__accordion.less']
},
files: {
'your-framework/master.less': ['your-framework/components/*/.less']
},
},
ui: {
options: {
copyExisting: true
},
files: {
'your-framework/master.less': ['your-framework/ui/*/.less', 'your-framework/variables.less']
},
},
},
})
``+ Initial Release
+ Added some options to mark specific files (components) as optional
+ Added an option to import files as reference via a custom file prefix