@@ -4,14 +4,14 @@ import { DISABLE_COMMENT_REG } from './lib/constant';
44import { createPropListMatcher } from './lib/filter-prop-list' ;
55import pixelUnitRegex from './lib/pixel-unit-regex' ;
66
7- export interface PxToRemOptions {
7+ export interface PxToLocalVarOptions {
88 /**
9- * rem 的根元素字体大小 ,计算 rem 值的基准 (rem = px / rootValue)。
9+ * scope rem的根元素字体大小 ,计算 scope rem 值的基准 (vw = px / rootValue)。
1010 * @default 16
1111 */
1212 rootValue ?: number ;
1313 /**
14- * 转换后 rem 值的小数点位数。
14+ * 转换后 scope rem 值的小数点位数。
1515 * @default 5
1616 */
1717 unitPrecision ?: number ;
@@ -52,7 +52,7 @@ export interface PxToRemOptions {
5252 varName ?: string ;
5353}
5454
55- const defaults : Required < PxToRemOptions > = {
55+ const defaults : Required < PxToLocalVarOptions > = {
5656 rootValue : 16 ,
5757 unitPrecision : 5 ,
5858 selectorBlackList : [ ] ,
@@ -64,7 +64,7 @@ const defaults: Required<PxToRemOptions> = {
6464 varName : '--local-scope-rem' ,
6565} ;
6666
67- function shouldExclude ( exclude : PxToRemOptions [ 'exclude' ] , file ?: string ) {
67+ function shouldExclude ( exclude : PxToLocalVarOptions [ 'exclude' ] , file ?: string ) {
6868 if ( ! exclude || ! file ) return false ;
6969 if ( typeof exclude === 'function' ) return exclude ( file ) ;
7070 if ( exclude instanceof RegExp ) return exclude . test ( file ) ;
@@ -75,7 +75,7 @@ function toFixed(number: number, precision: number) {
7575 return parseFloat ( number . toFixed ( precision ) ) . toString ( ) ;
7676}
7777
78- function createPxReplace ( opts : Required < PxToRemOptions > ) {
78+ function createPxReplace ( opts : Required < PxToLocalVarOptions > ) {
7979 return function ( m : string , $1 : string ) {
8080 if ( ! $1 ) return m ;
8181 const pixels = parseFloat ( $1 ) ;
@@ -108,13 +108,13 @@ function hasDisableNextLineComment(decl: Declaration): boolean {
108108 return false ;
109109}
110110
111- export const postcssPxToRem = ( options : PxToRemOptions = { } ) : Plugin => {
111+ export const postcssPxToLocalVar = ( options : PxToLocalVarOptions = { } ) : Plugin => {
112112 const opts = { ...defaults , ...options } ;
113113 const propListMatch = createPropListMatcher ( opts . propList ) ;
114114 const isBlackSelector = createSelectorBlackList ( opts . selectorBlackList ) ;
115115
116116 return {
117- postcssPlugin : 'postcss-px-to-rem ' ,
117+ postcssPlugin : 'postcss-px-to-local-var ' ,
118118 Once ( root : Root ) {
119119 const file = root . source ?. input . file ;
120120 if ( shouldExclude ( opts . exclude , file ) ) return ;
@@ -145,4 +145,4 @@ export const postcssPxToRem = (options: PxToRemOptions = {}): Plugin => {
145145 } ,
146146 } ;
147147} ;
148- postcssPxToRem . postcss = true ;
148+ postcssPxToLocalVar . postcss = true ;
0 commit comments