Gulp-sass compiles sass files using node-sass , which has an object with various options.

 sass( { outputStyle: 'expanded', // стиль вывода sourceComments: true, // добавляет комментарий перед селектором в выходном файле о строке где этот селектор в исходном файле. indentType: 'tab', // тип оступа indentWidth: 1, // величина отступа max-10 includePaths: ['dev/scss/base/', 'dev/scss/elements/'] // массив путей подключаемых файлов, вроде как должно решать проблему импортов... }) 

So, there is a functions object there and quite a bit of it is written in the documentation about it:

This is an experimental LibSass feature. Use with caution.

functions is an object that contains a set of user-defined functions that can be called using Sass files are compiled. They can take zero or more input parameters and should return a value either synchronously (return ...;) or asynchronously (done();) . These parameters will be instances of one of the constructors contained in the require('node-sass').types hashes. The return value must be a single name of these types. See the list of available types below: ......

I did not find more detailed documentation, and it is not quite clear for what purposes it can be used.
The importer option argument is also very interesting, as I understand it is used to define the user function for importing include files. I want details.
Knowledgeable people share information, preferably with examples :)

    1 answer 1

    Here is a little non-machine translation:

    functions is an object that contains a set of user-defined functions that can be called at compile time. They can have an arbitrary number of input parameters, and return the result both synchronously (return) and asynchronously (done). As input parameters you will receive type instances (written by constructors, since these are js) contained in the hash require ('node-sass'). Types. The return value must also be an instance of one of these types.

    Further in the document on your link follows a list of types that you can use as input parameters / return value of such functions, and then an example of their use, in which you can see how to write such a function, and how to use it inside Sass:

     sass.renderSync({ data: '#{headings(2,5)} { color: #08c; }', functions: { 'headings($from: 0, $to: 6)': function(from, to) { var i, f = from.getValue(), t = to.getValue(), list = new sass.types.List(t - f + 1); for (i = f; i <= t; i++) { list.setValue(i - f, new sass.types.String('h' + i)); } return list; } } }); 

    This example uses the javascript headings function, which takes two parameters of type sass.types.Number, and returns a list (sass.types.List) of strings (sass.types.String) of hX tags, where X, in this example, the number from 2 to 5.

    This is needed so you can write your function on js, and use it from Sass. Conveniently. Only it is better not to forget that the functionality is experimental.

    UPD:

    And the importer is needed for the manual resolution of imports, it is also described there in detail. This function (or several functions) that accepts the path to be split, the previous split path and the callback to call with your result.

    The result is an object with the "file" field, which contains the path to the desired file, or with the "contents" field, which already contains the contents of the file, and not the path to it.