weapp-tailwindcss
Version:
把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!
72 lines (67 loc) • 1.78 kB
JavaScript
// src/utils/index.ts
import { defu, defuOverrideArray, groupBy, isMap, isRegexp, noop, regExpTest, removeExt } from "@weapp-tailwindcss/shared";
// src/utils/hbuilderx.ts
import path from "path";
import process from "process";
// src/utils/uni-platform.ts
import process2 from "process";
function normalizePlatform(value) {
return value?.trim().toLowerCase() || void 0;
}
function resolveUniUtsPlatform(value = process2.env.UNI_UTS_PLATFORM) {
const normalized = normalizePlatform(value);
const isAppAndroid = normalized === "app-android";
const isAppIos = normalized === "app-ios";
const isAppHarmony = normalized === "app-harmony";
const isApp = normalized?.startsWith("app-") === true || normalized === "app" || normalized === "app-plus";
const isMp = normalized?.startsWith("mp-") === true;
const isWeb = normalized?.startsWith("web") === true || normalized === "h5";
return {
raw: value,
normalized,
isApp,
isAppAndroid,
isAppHarmony,
isAppIos,
isMp,
isWeb
};
}
// src/utils/index.ts
function classifyEntry(filename, options) {
if (options.cssMatcher(filename)) {
return "css";
}
if (options.htmlMatcher(filename)) {
return "html";
}
if (options.jsMatcher(filename) || options.wxsMatcher(filename)) {
return "js";
}
return "other";
}
function createEmptyGroups() {
return {
css: [],
html: [],
js: [],
other: []
};
}
function getGroupedEntries(entries, options) {
const groups = createEmptyGroups();
for (const entry of entries) {
const [filename] = entry;
const group = classifyEntry(filename, options);
groups[group].push(entry);
}
return groups;
}
export {
resolveUniUtsPlatform,
defu,
defuOverrideArray,
isMap,
noop,
getGroupedEntries
};