Sha256: 34d907c8ac7a22d4fa9d62073d07d1b8700562b2f43789cfd99911e2ab4c01d2

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

"use strict";

/**
 * Creates new custom importers that use the given `resourcePath` if libsass calls the custom importer with `prev`
 * being 'stdin'.
 *
 * Why do we need this? We have to use the `data` option of node-sass in order to compile our sass because
 * the `resourcePath` might not be an actual file on disk. When using the `data` option, libsass uses the string
 * 'stdin' instead of a filename.
 *
 * We have to fix this behavior in order to provide a consistent experience to the webpack user.
 *
 * @param {function|Array<function>} importer
 * @param {string} resourcePath
 * @returns {Array<function>}
 */
function proxyCustomImporters(importer, resourcePath) {
    return [].concat(importer).map((importer) => {
        return function (url, prev, done) {
            return importer.apply(
                this, // eslint-disable-line no-invalid-this
                Array.from(arguments)
                    .map((arg, i) => i === 1 && arg === "stdin" ? resourcePath : arg)
            );
        };
    });
}

module.exports = proxyCustomImporters;

Version data entries

10 entries across 8 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/sass-loader/lib/proxyCustomImporters.js
ilog-0.4.0 node_modules/sass-loader/lib/proxyCustomImporters.js
ilog-0.3.3 node_modules/sass-loader/lib/proxyCustomImporters.js
optimacms-0.4.3 spec/dummy/node_modules/@rails/webpacker/node_modules/sass-loader/lib/proxyCustomImporters.js
optimacms-0.4.3 spec/dummy/node_modules/sass-loader/lib/proxyCustomImporters.js
optimacms-0.4.2 spec/dummy/node_modules/sass-loader/lib/proxyCustomImporters.js
optimacms-0.4.2 spec/dummy/node_modules/@rails/webpacker/node_modules/sass-loader/lib/proxyCustomImporters.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/sass-loader/lib/proxyCustomImporters.js
locomotivecms-3.4.0 app/javascript/node_modules/sass-loader/lib/proxyCustomImporters.js
cortex-0.1.3 spec/dummy/node_modules/sass-loader/lib/proxyCustomImporters.js