@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
26 lines (25 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getStyleScopeHash = void 0;
var _includes = _interopRequireDefault(require("core-js-pure/stable/instance/includes.js"));
var _BuildInfo = require("../../shared/build-info/BuildInfo.js");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const slugify = s => String(s).toLowerCase().replace(/[^a-z0-9-]/g, '_');
const getStyleScopeHash = (opts = undefined) => {
var _context;
const version = opts?.version || (0, _BuildInfo.getVersion)();
const isVersion = String(version).match(/^\d/);
const isBranch = (0, _includes.default)(_context = String(version)).call(_context, '/');
if (isVersion) {
return slugify(`eufemia-scope--${version}`);
}
if (isBranch) {
const sha = opts?.sha || (0, _BuildInfo.getSha)();
return slugify(`eufemia-scope--${sha}`);
}
return 'eufemia-scope--default';
};
exports.getStyleScopeHash = getStyleScopeHash;
//# sourceMappingURL=plugin-scope-hash.js.map