t-comm
Version:
专业、稳定、纯粹的工具库
41 lines (40 loc) • 1.14 kB
TypeScript
interface RpxToPxPluginOptions {
/** rpx 到 px 的转换比例,默认 0.5(基于 750 设计稿) */
ratio?: number;
/** 在哪些平台执行,默认 ['h5']。通过 process.env.UNI_PLATFORM 判断 */
platform?: string[];
}
/**
* PostCSS 插件:将 rpx 单位转换为 px
*
* 基于 750 设计稿,1rpx = 0.5px。
* 内置平台判断,默认仅在 h5 平台执行。
*
* @param {object} options - 配置选项
* @param {number} options.ratio - rpx 到 px 的转换比例,默认 0.5
* @param {string[]} options.platform - 在哪些平台执行,默认 ['h5']
*
* @example
*
* ```js
* // postcss.config.js
* const { rpxToPxPlugin } = require('t-comm');
*
* module.exports = {
* plugins: [
* // 默认仅在 h5 平台执行,无需外部判断
* rpxToPxPlugin(),
* // 自定义比例和平台
* rpxToPxPlugin({ ratio: 1, platform: ['h5', 'mp-weixin'] }),
* ],
* };
* ```
*/
export declare const rpxToPxPlugin: {
(options?: RpxToPxPluginOptions): {
postcssPlugin: string;
Declaration(decl: any): void;
};
postcss: boolean;
};
export {};