ngx-unused-css
Version:
Detect unused CSS in angular components
34 lines • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var path_1 = (0, tslib_1.__importDefault)(require("path"));
var sass_1 = (0, tslib_1.__importDefault)(require("sass"));
var url_1 = require("url");
/**
* Compile styling file
* @param {string} cssPath
*/
function compileSCSS(cssPath, config) {
var _a;
var options = {
importers: [
{
// An importer that redirects relative URLs starting with "~" to
// `node_modules`.
findFileUrl: function (url) {
if (!url.startsWith('~'))
return null;
return new URL(path_1.default.join('node_modules', url.substring(1)), (0, url_1.pathToFileURL)('node_modules'));
}
}
],
loadPaths: config.includePaths
};
if (config.importer) {
(_a = options.importers) === null || _a === void 0 ? void 0 : _a.push(config.importer);
}
var result = sass_1.default.compile(cssPath, options);
return result.css.toString();
}
exports.default = compileSCSS;
//# sourceMappingURL=compileSCSS.js.map