add-less-import
Add an
@import
statement into a .less file at a specific point.
This is completely experimental and pretty hacky. I created this as a proof of concept for another project I'm working on, so it's also limited in scope. Currently, this will only add a single less file at a time, and the formatting and parsing logic are fairly rudimentary.
Install
Install with npm:
npm i add-less-import --save-dev
Usage
Pass a string, the import statement to add, and a keyword in a code comment that indicates where you want the @import
statement to be added.
Duplicates will only be uniqued when they are in the same "section".
Example
Assuming you have a .less
file and it looks something like this:
// // Styles // -------------------------------------------- // Variables and mixins "variables.less"; "mixins.less"; // Components "alerts.less"; "buttons.less"; // Utilities "utilities.less";
Here is how you would add import statements:
var addImport = ;var str = fs; // obviously you would probably want to do this dynamically,// like with command line arguments. this is just an example;
The result would be:
// // Styles // -------------------------------------------- // Variables and mixins "variables.less"; "mixins.less"; // Components "alerts.less"; "buttons.less"; "nav.less"; // Utilities "utilities.less";
str
{String}:section
{String}: The code-comment keyword to search for.statement
{String}: The full import statement.options
{Object}:return
{String}
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on June 02, 2014.