83 lines
3.3 KiB
JavaScript
83 lines
3.3 KiB
JavaScript
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
mod
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
var sass_inline_transformer_exports = {};
|
|
__export(sass_inline_transformer_exports, {
|
|
SassInlineTransformer: () => SassInlineTransformer
|
|
});
|
|
module.exports = __toCommonJS(sass_inline_transformer_exports);
|
|
var import_path = __toESM(require("path"));
|
|
var import_glob = __toESM(require("glob"));
|
|
var import_lodash = __toESM(require("lodash"));
|
|
var import_baka = __toESM(require("@joneff/baka"));
|
|
var import_utils = require("../utils");
|
|
const SassInlineTransformer = {
|
|
transformFile,
|
|
transformGlob
|
|
};
|
|
function transformFile(file, outFile, options) {
|
|
const _cwd = options.cwd;
|
|
if (import_path.default.isAbsolute(file) === false) {
|
|
file = (0, import_utils.padCwd)(_cwd, file);
|
|
}
|
|
if (import_path.default.isAbsolute(outFile) === false) {
|
|
outFile = (0, import_utils.padCwd)(_cwd, outFile);
|
|
}
|
|
import_utils.logger.info(
|
|
"transform",
|
|
"%s => %s",
|
|
(0, import_utils.trimCwd)(import_utils.CWD, file),
|
|
(0, import_utils.trimCwd)(import_utils.CWD, outFile)
|
|
);
|
|
const result = import_baka.default.compile(file, { cwd: _cwd });
|
|
(0, import_utils.writeFile)(outFile, result.content);
|
|
}
|
|
function transformGlob(fileOrGlob, output, options) {
|
|
const _cwd = options.cwd;
|
|
if ((0, import_utils.isString)(fileOrGlob)) {
|
|
import_utils.logger.warn("cli > config > transform > transformGlob", "Prefer string[] for fileOrGlob option.");
|
|
fileOrGlob = [fileOrGlob];
|
|
}
|
|
output = import_lodash.default.defaults({}, output, { path: "dist", filename: "[name].css" });
|
|
if (import_path.default.isAbsolute(output.path) === false) {
|
|
output.path = (0, import_utils.padCwd)(_cwd, output.path);
|
|
}
|
|
fileOrGlob.forEach((fileOrGlob2) => {
|
|
if (import_path.default.isAbsolute(fileOrGlob2) === false) {
|
|
fileOrGlob2 = (0, import_utils.padCwd)(_cwd, fileOrGlob2);
|
|
}
|
|
fileOrGlob2 = fileOrGlob2.split(import_path.default.sep).join(import_path.default.posix.sep);
|
|
import_glob.default.sync(fileOrGlob2).forEach((file) => {
|
|
const outFile = import_path.default.resolve(
|
|
output.path,
|
|
(0, import_utils.replacePathVariables)(output.filename, file)
|
|
);
|
|
transformFile(file, outFile, options);
|
|
});
|
|
});
|
|
}
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
SassInlineTransformer
|
|
});
|