@nutui/nutui
Version:
京东风格的轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)
25 lines (24 loc) • 841 B
JavaScript
;
const nutFunctions = ["showToast", "showNotify", "showDialog", "showImagePreview"];
function getNutResolved(name, options) {
const { taro = false, autoImport = false } = options;
const packageName = taro ? "@nutui/nutui-taro" : "@nutui/nutui";
const componentName = autoImport ? name.slice(4) : name;
const style = `${packageName}/dist/packages/${componentName.toLowerCase()}/style`;
return {
name,
from: packageName,
sideEffects: style
};
}
function NutUIResolver(options = {}) {
return {
type: "component",
resolve: (name) => {
const { autoImport = false } = options;
if (autoImport && nutFunctions.includes(name)) return getNutResolved(name, options);
if (name.startsWith("Nut")) return getNutResolved(name.slice(3), options);
}
};
}
module.exports = NutUIResolver;