management/front/dkha-web-sz-main/node_modules/clean-css/lib/urls/rebase.js

31 lines
858 B
JavaScript
Raw Normal View History

2023-12-18 13:12:25 +08:00
var path = require('path');
var rewriteUrls = require('./rewrite');
function rebaseUrls(data, context) {
var rebaseOpts = {
absolute: context.options.explicitRoot,
relative: !context.options.explicitRoot && context.options.explicitTarget,
fromBase: context.options.relativeTo
};
if (!rebaseOpts.absolute && !rebaseOpts.relative)
return data;
if (rebaseOpts.absolute && context.options.explicitTarget)
context.warnings.push('Both \'root\' and output file given so rebasing URLs as absolute paths');
if (rebaseOpts.absolute)
rebaseOpts.toBase = path.resolve(context.options.root);
if (rebaseOpts.relative)
rebaseOpts.toBase = path.resolve(context.options.target);
if (!rebaseOpts.fromBase || !rebaseOpts.toBase)
return data;
return rewriteUrls(data, rebaseOpts, context);
}
module.exports = rebaseUrls;