less-imports-extractor

0.0.3 • Public • Published

less-imports-extractor

  • Extract .less files @imports recursively with content
  • Considers include paths when looking for an import file

How to use?

var extractor = require('less-imports-extractor');
 
extractor.getImportsByPath('./main.less', ['./global_includes', './another/'])
.then(function(result) {
    console.log(result);
})
.catch(function(e) {
    console.log("Err:", e);
})
.done()

Result:

{
    tree : {
        content: 'file content',
        imports: [ [Object], [Object], [Object] ],
        absolutePath: '/absolute/path.less'
    },

    flat: [
        {
            absolutePath: '/absolute/path.less',
            content: 'less file content'
        },
        {
            importFile : 'path.less',
            importOptions : [],
            absolutePath: '/absolute/path.less',
            content: 'less file content'
        }
    ]
}

API

getImportsByPath(lessPath, includePaths)

  • lessPath - path to less file
  • includePaths - an array with path where to search for an import file

Readme

Keywords

none

Package Sidebar

Install

npm i less-imports-extractor

Weekly Downloads

1

Version

0.0.3

License

MIT

Last publish

Collaborators

  • kirill-zhirnov