weapp-tailwindcss
Version:
把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!
115 lines (101 loc) • 3.46 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
var _chunkPT4IJT3Qjs = require('./chunk-PT4IJT3Q.js');
var _chunkFMBPNII7js = require('./chunk-FMBPNII7.js');
require('./chunk-MB4BR57E.js');
// src/presets/shared.ts
function normalizeCssEntries(entries) {
if (!entries) {
return void 0;
}
const normalized = Array.isArray(entries) ? entries : [entries];
return normalized.length > 0 ? normalized : void 0;
}
function createBasePreset(options = {}) {
const {
base,
cssEntries,
resolve,
rawOptions,
...userOptions
} = options;
const baseDir = _chunkPT4IJT3Qjs.resolveTailwindcssBasedir.call(void 0, base);
const normalizedCssEntries = normalizeCssEntries(cssEntries);
const tailwindConfig = {
v2: { cwd: baseDir },
v3: { cwd: baseDir },
v4: {
base: baseDir,
cssEntries: normalizedCssEntries
}
};
if (normalizedCssEntries && normalizedCssEntries.length > 0) {
tailwindConfig.version = 4;
}
const patchTailwindConfig = resolve ? {
...tailwindConfig,
resolve
} : tailwindConfig;
const preset = {
tailwindcssBasedir: baseDir,
tailwindcss: tailwindConfig,
tailwindcssPatcherOptions: {
cwd: baseDir,
tailwind: patchTailwindConfig
}
};
const mergedUserOptions = _chunkFMBPNII7js.defuOverrideArray.call(void 0, userOptions, _nullishCoalesce(rawOptions, () => ( {})));
return _chunkFMBPNII7js.defuOverrideArray.call(void 0,
mergedUserOptions,
preset
);
}
// src/presets/uni-app.ts
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
function uniApp(options = {}) {
const uniPlatform = _process2.default.env.UNI_PLATFORM;
const disableInH5OrApp = uniPlatform === "h5" || uniPlatform === "app" || uniPlatform === "app-plus";
return createBasePreset({
disabled: disableInH5OrApp ? true : void 0,
...options
});
}
// src/presets/uni-app-x.ts
function uniAppX(options) {
_chunkPT4IJT3Qjs.logger.info(`UNI_PLATFORM: ${_process2.default.env.UNI_PLATFORM}`);
const isApp = _process2.default.env.UNI_PLATFORM === "app" || _process2.default.env.UNI_PLATFORM === "app-plus" || _process2.default.env.UNI_PLATFORM === "app-harmony";
const cssEntries = normalizeCssEntries(options.cssEntries);
return _chunkFMBPNII7js.defuOverrideArray.call(void 0,
_nullishCoalesce(options.rawOptions, () => ( {})),
{
uniAppX: isApp,
rem2rpx: options.rem2rpx,
tailwindcssBasedir: options.base,
tailwindcssPatcherOptions: {
cwd: options.base,
tailwind: {
cwd: options.base,
resolve: options.resolve,
v3: {
cwd: options.base
},
v4: {
base: options.base,
cssEntries
}
}
},
cssPreflight: {
"border-style": false
},
cssPresetEnv: {
features: {
"custom-properties": {
preserve: false
}
}
},
...options.customAttributes ? { customAttributes: options.customAttributes } : {}
}
);
}
exports.createBasePreset = createBasePreset; exports.normalizeCssEntries = normalizeCssEntries; exports.uniApp = uniApp; exports.uniAppX = uniAppX;