UNPKG

weapp-tailwindcss

Version:

把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!

116 lines (115 loc) 3.13 kB
import { a as noop } from "./utils-MVwpU07P.js"; import { t as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH } from "./cache-options-DwBtLwQe.js"; import { MappingChars2String, isAllowedClassName } from "@weapp-core/escape"; //#region src/defaults.ts const CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/; const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/; const JS_FILE_PATTERN = /.+\.[cm]?js?$/; const alwaysFalse = () => false; const TAILWIND_V4_CSS_PREFLIGHT = { "border": "0 solid", "box-sizing": "border-box", "margin": "0", "padding": "0" }; function getDefaultCssPreflight() { return { ...TAILWIND_V4_CSS_PREFLIGHT }; } function resolveDefaultCssPreflight(cssPreflight, _tailwindcssMajorVersion) { if (cssPreflight === false) return false; return { ...getDefaultCssPreflight(), ...cssPreflight ?? {} }; } 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); }, transform: { include: [], exclude: [] }, mainCssChunkMatcher: alwaysFalse, wxsMatcher: alwaysFalse, cssPreflight: getDefaultCssPreflight(), disabled: false, onLoad: noop, onStart: noop, onEnd: noop, onUpdate: noop, customAttributes: {}, customReplaceDictionary: MappingChars2String, appType: void 0, arbitraryValues: { allowDoubleQuotes: false, bareArbitraryValues: false }, unocss: false, cssChildCombinatorReplaceValue: ["view", "text"], inlineWxs: false, injectAdditionalCssVarScope: false, jsPreserveClass: (keyword) => { /** * 默认保留 keyword */ if (keyword === "*") return true; return false; }, disabledDefaultTemplateHandler: false, cssSelectorReplacement: { root: [ "page", ".tw-root", "wx-root-portal-content" ], universal: ["view", "text"] }, babelParserOptions: { sourceType: "unambiguous", cache: true, cacheKey: "st:unambiguous", cacheMaxEntries: 128, cacheMaxSourceLength: DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH }, postcssOptions: {}, cssRemoveProperty: true, cssRemoveHoverPseudoClass: true, ignoreCallExpressionIdentifiers: [], ignoreTaggedTemplateExpressionIdentifiers: ["weappTwIgnore"], replaceRuntimePackages: false, rewriteCssImports: false, generator: {}, cssSourceTrace: false, tailwindcssRuntimeOptions: { filter(className) { return !isAllowedClassName(className); } }, logLevel: "info" }; } //#endregion export { TAILWIND_V4_CSS_PREFLIGHT, getDefaultCssPreflight, getDefaultOptions, resolveDefaultCssPreflight };