weapp-tailwindcss
Version:
把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!
132 lines (126 loc) • 4.09 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _chunkFMBPNII7js = require('./chunk-FMBPNII7.js');
// src/defaults.ts
var _escape = require('@weapp-core/escape');
var CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
var HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
var JS_FILE_PATTERN = /.+\.[cm]?js?$/;
function normalizePath(p) {
return p.replace(/\\/g, "/");
}
var MPX_STYLES_DIR_PATTERN = /(?:^|\/)styles\/.*\.(?:wx|ac|jx|tt|q|c|ty)ss$/i;
var MAIN_CSS_CHUNK_MATCHERS = {
"uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
"uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
"mpx": (file) => {
const normalized = normalizePath(file);
if (normalized.startsWith("app")) {
return true;
}
return MPX_STYLES_DIR_PATTERN.test(normalized);
},
"taro": (file) => file.startsWith("app"),
"remax": (file) => file.startsWith("app"),
"rax": (file) => file.startsWith("bundle"),
"native": (file) => file.startsWith("app"),
"kbone": (file) => /^(?:common\/)?miniprogram-app/.test(file)
};
var alwaysFalse = () => false;
function createMainCssChunkMatcher() {
return (file, appType) => {
if (!appType) {
return true;
}
const matcher = MAIN_CSS_CHUNK_MATCHERS[appType];
return matcher ? matcher(file) : true;
};
}
function getDefaultOptions() {
return {
/**
* wxss 微信小程序
* acss 支付宝小程序
* jxss 京东小程序
* ttss 头条小程序
* qss QQ小程序
* css 最正常的样式文件
* tyss 涂鸦小程序
*/
cssMatcher: (file) => CSS_FILE_PATTERN.test(file),
/**
* wxml 微信小程序
* axml 支付宝小程序
* jxml 京东小程序
* ksml 快手小程序
* ttml 头条小程序
* qml QQ小程序
* tyml 涂鸦小程序
* xhsml 小红书小程序
* swan 百度小程序
*/
htmlMatcher: (file) => HTML_FILE_PATTERN.test(file),
jsMatcher: (file) => {
if (file.includes("node_modules")) {
return false;
}
return JS_FILE_PATTERN.test(file);
},
mainCssChunkMatcher: createMainCssChunkMatcher(),
wxsMatcher: alwaysFalse,
// 参考:https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
cssPreflight: {
"box-sizing": "border-box",
"border-width": "0",
"border-style": "solid",
"border-color": "currentColor"
},
disabled: false,
onLoad: _chunkFMBPNII7js.noop,
onStart: _chunkFMBPNII7js.noop,
onEnd: _chunkFMBPNII7js.noop,
onUpdate: _chunkFMBPNII7js.noop,
customAttributes: {},
customReplaceDictionary: _escape.MappingChars2String,
appType: void 0,
arbitraryValues: {
allowDoubleQuotes: false
},
cssChildCombinatorReplaceValue: ["view", "text"],
inlineWxs: false,
injectAdditionalCssVarScope: false,
rewriteCssImports: true,
jsPreserveClass: (keyword) => {
if (keyword === "*") {
return true;
}
return false;
},
disabledDefaultTemplateHandler: false,
cssSelectorReplacement: {
root: ["page", ".tw-root"],
universal: ["view", "text"]
},
babelParserOptions: {
sourceType: "unambiguous",
cache: true,
// 预计算好的 cacheKey,避免重复对选项进行 JSON.stringify
cacheKey: "st:unambiguous"
},
postcssOptions: {},
// 开发版本微信小程序工具和小米13手机上 @property 是有效果的
// 支付宝小程序会直接挂掉
// https://developer.mozilla.org/en-US/docs/Web/CSS/@property
cssRemoveProperty: true,
cssRemoveHoverPseudoClass: true,
ignoreCallExpressionIdentifiers: [],
ignoreTaggedTemplateExpressionIdentifiers: ["weappTwIgnore"],
replaceRuntimePackages: false,
tailwindcssPatcherOptions: {
filter(className) {
return !_escape.isAllowedClassName.call(void 0, className);
}
},
logLevel: "info"
};
}
exports.getDefaultOptions = getDefaultOptions;