morjs-plugin-compiler-xhs
Version:
mor compiler plugin for xiaohongshu miniprogram
32 lines • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var constants_1 = require("./constants");
var XHSCompilerPlugin = /** @class */ (function () {
function XHSCompilerPlugin() {
this.name = 'XHSCompilerPlugin';
}
XHSCompilerPlugin.prototype.apply = function (runner) {
var _this = this;
runner.hooks.beforeRun.tap(this.name, function () {
_this.runner = runner;
var _a = _this.runner.userConfig, sourceType = _a.sourceType, target = _a.target;
if (sourceType === target)
return;
_this.runner.hooks.configParser.tapPromise(_this.name, function (config, options) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var componentName;
return tslib_1.__generator(this, function (_a) {
for (componentName in config.usingComponents || {}) {
if (config.usingComponents[componentName].endsWith(constants_1.fileType.template)) {
config.usingComponents[componentName] = config.usingComponents[componentName].replace(constants_1.fileType.template, '');
}
}
return [2 /*return*/, config]; // 确保 return 在 for 循环外部
});
}); });
});
};
return XHSCompilerPlugin;
}());
exports.default = XHSCompilerPlugin;
//# sourceMappingURL=plugin.js.map