@weapp-tailwindcss/postcss 1.0.0-alpha.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +49 -32
- package/dist/index.mjs +50 -33
- package/dist/types-DiXihH4o.d.mts +63 -0
- package/dist/types-DiXihH4o.d.ts +63 -0
- package/dist/types.d.mts +3 -2
- package/dist/types.d.ts +3 -2
- package/package.json +5 -5
- package/dist/types-BlpvjUzB.d.mts +0 -183
- package/dist/types-BlpvjUzB.d.ts +0 -183
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-
|
|
2
|
-
export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions, c as createInjectPreflight } from './types-
|
|
1
|
+
import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-DiXihH4o.mjs';
|
|
2
|
+
export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions, c as createInjectPreflight } from './types-DiXihH4o.mjs';
|
|
3
3
|
import postcss from 'postcss';
|
|
4
|
-
import '@weapp-tailwindcss/mangle
|
|
4
|
+
import '@weapp-tailwindcss/mangle';
|
|
5
5
|
import 'postcss-load-config';
|
|
6
|
+
import 'postcss-preset-env';
|
|
6
7
|
import 'postcss-rem-to-responsive-pixel';
|
|
7
8
|
|
|
8
|
-
declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): Promise<postcss.Result<postcss.Document | postcss.Root>>;
|
|
9
9
|
declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
|
|
10
10
|
|
|
11
11
|
declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
|
|
12
12
|
|
|
13
|
-
export { IStyleHandlerOptions, InternalCssSelectorReplacerOptions, createStyleHandler, internalCssSelectorReplacer
|
|
13
|
+
export { IStyleHandlerOptions, InternalCssSelectorReplacerOptions, createStyleHandler, internalCssSelectorReplacer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-
|
|
2
|
-
export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions, c as createInjectPreflight } from './types-
|
|
1
|
+
import { I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions } from './types-DiXihH4o.js';
|
|
2
|
+
export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions, c as createInjectPreflight } from './types-DiXihH4o.js';
|
|
3
3
|
import postcss from 'postcss';
|
|
4
|
-
import '@weapp-tailwindcss/mangle
|
|
4
|
+
import '@weapp-tailwindcss/mangle';
|
|
5
5
|
import 'postcss-load-config';
|
|
6
|
+
import 'postcss-preset-env';
|
|
6
7
|
import 'postcss-rem-to-responsive-pixel';
|
|
7
8
|
|
|
8
|
-
declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): Promise<postcss.Result<postcss.Document | postcss.Root>>;
|
|
9
9
|
declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
|
|
10
10
|
|
|
11
11
|
declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
|
|
12
12
|
|
|
13
|
-
export { IStyleHandlerOptions, InternalCssSelectorReplacerOptions, createStyleHandler, internalCssSelectorReplacer
|
|
13
|
+
export { IStyleHandlerOptions, InternalCssSelectorReplacerOptions, createStyleHandler, internalCssSelectorReplacer };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,26 @@
|
|
|
4
4
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
5
5
|
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
6
6
|
|
|
7
|
+
// src/defaults.ts
|
|
8
|
+
function getDefaultOptions() {
|
|
9
|
+
return {
|
|
10
|
+
cssPresetEnv: {
|
|
11
|
+
features: {
|
|
12
|
+
"cascade-layers": true,
|
|
13
|
+
"is-pseudo-class": {
|
|
14
|
+
specificityMatchingName: "weapp-tw-ig"
|
|
15
|
+
},
|
|
16
|
+
"oklab-function": true,
|
|
17
|
+
"color-mix": true,
|
|
18
|
+
"custom-properties": false
|
|
19
|
+
},
|
|
20
|
+
autoprefixer: {
|
|
21
|
+
add: false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
7
27
|
// src/plugins/index.ts
|
|
8
28
|
var _postcsspresetenv = require('postcss-preset-env'); var _postcsspresetenv2 = _interopRequireDefault(_postcsspresetenv);
|
|
9
29
|
var _postcssremtoresponsivepixel = require('postcss-rem-to-responsive-pixel'); var _postcssremtoresponsivepixel2 = _interopRequireDefault(_postcssremtoresponsivepixel);
|
|
@@ -552,10 +572,10 @@ var postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
552
572
|
};
|
|
553
573
|
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
554
574
|
|
|
555
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.
|
|
575
|
+
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.2/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
556
576
|
|
|
557
577
|
|
|
558
|
-
// ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.
|
|
578
|
+
// ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.1.0/node_modules/@csstools/selector-specificity/dist/index.mjs
|
|
559
579
|
|
|
560
580
|
function compare(e3, t2) {
|
|
561
581
|
return e3.a === t2.a ? e3.b === t2.b ? e3.c - t2.c : e3.b - t2.b : e3.a - t2.a;
|
|
@@ -660,7 +680,7 @@ function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
|
660
680
|
return 0 === t2.length || 1 === t2.length && "universal" === t2[0].type;
|
|
661
681
|
}
|
|
662
682
|
|
|
663
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.
|
|
683
|
+
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.2/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
664
684
|
function alwaysValidSelector(s) {
|
|
665
685
|
const o2 = _postcssselectorparser2.default.call(void 0, ).astSync(s);
|
|
666
686
|
let t2 = true;
|
|
@@ -864,16 +884,7 @@ function getPlugins(options) {
|
|
|
864
884
|
const plugins = [
|
|
865
885
|
..._nullishCoalesce(_optionalChain([options, 'access', _44 => _44.postcssOptions, 'optionalAccess', _45 => _45.plugins]), () => ( [])),
|
|
866
886
|
postcssWeappTailwindcssPrePlugin(options),
|
|
867
|
-
_postcsspresetenv2.default.call(void 0,
|
|
868
|
-
features: {
|
|
869
|
-
"cascade-layers": true,
|
|
870
|
-
"is-pseudo-class": {
|
|
871
|
-
specificityMatchingName: "weapp-tw-ig"
|
|
872
|
-
},
|
|
873
|
-
"oklab-function": true,
|
|
874
|
-
"color-mix": true
|
|
875
|
-
}
|
|
876
|
-
})
|
|
887
|
+
_postcsspresetenv2.default.call(void 0, options.cssPresetEnv)
|
|
877
888
|
];
|
|
878
889
|
if (options.rem2rpx) {
|
|
879
890
|
plugins.push(
|
|
@@ -890,24 +901,6 @@ function getPlugins(options) {
|
|
|
890
901
|
return plugins;
|
|
891
902
|
}
|
|
892
903
|
|
|
893
|
-
// src/handler.ts
|
|
894
|
-
function styleHandler(rawSource, options) {
|
|
895
|
-
return _postcss2.default.call(void 0, getPlugins(options)).process(
|
|
896
|
-
rawSource,
|
|
897
|
-
_nullishCoalesce(_optionalChain([options, 'access', _46 => _46.postcssOptions, 'optionalAccess', _47 => _47.options]), () => ( {
|
|
898
|
-
from: void 0
|
|
899
|
-
}))
|
|
900
|
-
).async();
|
|
901
|
-
}
|
|
902
|
-
function createStyleHandler(options) {
|
|
903
|
-
return (rawSource, opt) => {
|
|
904
|
-
return styleHandler(
|
|
905
|
-
rawSource,
|
|
906
|
-
_shared.defuOverrideArray.call(void 0, opt, options)
|
|
907
|
-
);
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
|
|
911
904
|
// src/preflight.ts
|
|
912
905
|
function createInjectPreflight(options) {
|
|
913
906
|
const result = [];
|
|
@@ -927,8 +920,32 @@ function createInjectPreflight(options) {
|
|
|
927
920
|
};
|
|
928
921
|
}
|
|
929
922
|
|
|
923
|
+
// src/handler.ts
|
|
924
|
+
function styleHandler(rawSource, options) {
|
|
925
|
+
return _postcss2.default.call(void 0,
|
|
926
|
+
getPlugins(options)
|
|
927
|
+
).process(
|
|
928
|
+
rawSource,
|
|
929
|
+
_nullishCoalesce(_optionalChain([options, 'access', _46 => _46.postcssOptions, 'optionalAccess', _47 => _47.options]), () => ( {
|
|
930
|
+
from: void 0
|
|
931
|
+
}))
|
|
932
|
+
).async();
|
|
933
|
+
}
|
|
934
|
+
function createStyleHandler(options) {
|
|
935
|
+
const cachedOptions = _shared.defuOverrideArray.call(void 0,
|
|
936
|
+
options,
|
|
937
|
+
getDefaultOptions()
|
|
938
|
+
);
|
|
939
|
+
cachedOptions.cssInjectPreflight = createInjectPreflight(cachedOptions.cssPreflight);
|
|
940
|
+
return (rawSource, opt) => {
|
|
941
|
+
return styleHandler(
|
|
942
|
+
rawSource,
|
|
943
|
+
_shared.defuOverrideArray.call(void 0, opt, cachedOptions)
|
|
944
|
+
);
|
|
945
|
+
};
|
|
946
|
+
}
|
|
930
947
|
|
|
931
948
|
|
|
932
949
|
|
|
933
950
|
|
|
934
|
-
exports.createInjectPreflight = createInjectPreflight; exports.createStyleHandler = createStyleHandler; exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
|
|
951
|
+
exports.createInjectPreflight = createInjectPreflight; exports.createStyleHandler = createStyleHandler; exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,26 @@ import "./chunk-WAXGOBY2.mjs";
|
|
|
4
4
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
5
5
|
import postcss from "postcss";
|
|
6
6
|
|
|
7
|
+
// src/defaults.ts
|
|
8
|
+
function getDefaultOptions() {
|
|
9
|
+
return {
|
|
10
|
+
cssPresetEnv: {
|
|
11
|
+
features: {
|
|
12
|
+
"cascade-layers": true,
|
|
13
|
+
"is-pseudo-class": {
|
|
14
|
+
specificityMatchingName: "weapp-tw-ig"
|
|
15
|
+
},
|
|
16
|
+
"oklab-function": true,
|
|
17
|
+
"color-mix": true,
|
|
18
|
+
"custom-properties": false
|
|
19
|
+
},
|
|
20
|
+
autoprefixer: {
|
|
21
|
+
add: false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
7
27
|
// src/plugins/index.ts
|
|
8
28
|
import postcssPresetEnv from "postcss-preset-env";
|
|
9
29
|
import postcssRem2rpx from "postcss-rem-to-responsive-pixel";
|
|
@@ -552,10 +572,10 @@ var postcssWeappTailwindcssPrePlugin = (options = {
|
|
|
552
572
|
};
|
|
553
573
|
postcssWeappTailwindcssPrePlugin.postcss = true;
|
|
554
574
|
|
|
555
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.
|
|
575
|
+
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.2/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
556
576
|
import e2 from "postcss-selector-parser";
|
|
557
577
|
|
|
558
|
-
// ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.
|
|
578
|
+
// ../../node_modules/.pnpm/@csstools+selector-specificity@5.0.0_postcss-selector-parser@7.1.0/node_modules/@csstools/selector-specificity/dist/index.mjs
|
|
559
579
|
import e from "postcss-selector-parser";
|
|
560
580
|
function compare(e3, t2) {
|
|
561
581
|
return e3.a === t2.a ? e3.b === t2.b ? e3.c - t2.c : e3.b - t2.b : e3.a - t2.a;
|
|
@@ -660,7 +680,7 @@ function selectorNodeContainsNothingOrOnlyUniversal(e3) {
|
|
|
660
680
|
return 0 === t2.length || 1 === t2.length && "universal" === t2[0].type;
|
|
661
681
|
}
|
|
662
682
|
|
|
663
|
-
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.
|
|
683
|
+
// ../../node_modules/.pnpm/@csstools+postcss-is-pseudo-class@5.0.1_postcss@8.5.2/node_modules/@csstools/postcss-is-pseudo-class/dist/index.mjs
|
|
664
684
|
function alwaysValidSelector(s) {
|
|
665
685
|
const o2 = e2().astSync(s);
|
|
666
686
|
let t2 = true;
|
|
@@ -864,16 +884,7 @@ function getPlugins(options) {
|
|
|
864
884
|
const plugins = [
|
|
865
885
|
...options.postcssOptions?.plugins ?? [],
|
|
866
886
|
postcssWeappTailwindcssPrePlugin(options),
|
|
867
|
-
postcssPresetEnv(
|
|
868
|
-
features: {
|
|
869
|
-
"cascade-layers": true,
|
|
870
|
-
"is-pseudo-class": {
|
|
871
|
-
specificityMatchingName: "weapp-tw-ig"
|
|
872
|
-
},
|
|
873
|
-
"oklab-function": true,
|
|
874
|
-
"color-mix": true
|
|
875
|
-
}
|
|
876
|
-
})
|
|
887
|
+
postcssPresetEnv(options.cssPresetEnv)
|
|
877
888
|
];
|
|
878
889
|
if (options.rem2rpx) {
|
|
879
890
|
plugins.push(
|
|
@@ -890,24 +901,6 @@ function getPlugins(options) {
|
|
|
890
901
|
return plugins;
|
|
891
902
|
}
|
|
892
903
|
|
|
893
|
-
// src/handler.ts
|
|
894
|
-
function styleHandler(rawSource, options) {
|
|
895
|
-
return postcss(getPlugins(options)).process(
|
|
896
|
-
rawSource,
|
|
897
|
-
options.postcssOptions?.options ?? {
|
|
898
|
-
from: void 0
|
|
899
|
-
}
|
|
900
|
-
).async();
|
|
901
|
-
}
|
|
902
|
-
function createStyleHandler(options) {
|
|
903
|
-
return (rawSource, opt) => {
|
|
904
|
-
return styleHandler(
|
|
905
|
-
rawSource,
|
|
906
|
-
defuOverrideArray(opt, options)
|
|
907
|
-
);
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
|
|
911
904
|
// src/preflight.ts
|
|
912
905
|
function createInjectPreflight(options) {
|
|
913
906
|
const result = [];
|
|
@@ -926,9 +919,33 @@ function createInjectPreflight(options) {
|
|
|
926
919
|
return result;
|
|
927
920
|
};
|
|
928
921
|
}
|
|
922
|
+
|
|
923
|
+
// src/handler.ts
|
|
924
|
+
function styleHandler(rawSource, options) {
|
|
925
|
+
return postcss(
|
|
926
|
+
getPlugins(options)
|
|
927
|
+
).process(
|
|
928
|
+
rawSource,
|
|
929
|
+
options.postcssOptions?.options ?? {
|
|
930
|
+
from: void 0
|
|
931
|
+
}
|
|
932
|
+
).async();
|
|
933
|
+
}
|
|
934
|
+
function createStyleHandler(options) {
|
|
935
|
+
const cachedOptions = defuOverrideArray(
|
|
936
|
+
options,
|
|
937
|
+
getDefaultOptions()
|
|
938
|
+
);
|
|
939
|
+
cachedOptions.cssInjectPreflight = createInjectPreflight(cachedOptions.cssPreflight);
|
|
940
|
+
return (rawSource, opt) => {
|
|
941
|
+
return styleHandler(
|
|
942
|
+
rawSource,
|
|
943
|
+
defuOverrideArray(opt, cachedOptions)
|
|
944
|
+
);
|
|
945
|
+
};
|
|
946
|
+
}
|
|
929
947
|
export {
|
|
930
948
|
createInjectPreflight,
|
|
931
949
|
createStyleHandler,
|
|
932
|
-
internalCssSelectorReplacer
|
|
933
|
-
styleHandler
|
|
950
|
+
internalCssSelectorReplacer
|
|
934
951
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { IMangleScopeContext } from '@weapp-tailwindcss/mangle';
|
|
2
|
+
import { Rule } from 'postcss';
|
|
3
|
+
import { Result } from 'postcss-load-config';
|
|
4
|
+
import { pluginOptions } from 'postcss-preset-env';
|
|
5
|
+
import { UserDefinedOptions } from 'postcss-rem-to-responsive-pixel';
|
|
6
|
+
|
|
7
|
+
declare function createContext(): {
|
|
8
|
+
variablesScopeWeakMap: WeakMap<WeakKey, any>;
|
|
9
|
+
isVariablesScope: (rule: WeakKey) => boolean;
|
|
10
|
+
markVariablesScope: (rule: WeakKey) => void;
|
|
11
|
+
};
|
|
12
|
+
type IContext = ReturnType<typeof createContext>;
|
|
13
|
+
|
|
14
|
+
type InjectPreflight = () => IPropValue[];
|
|
15
|
+
declare function createInjectPreflight(options?: CssPreflightOptions): InjectPreflight;
|
|
16
|
+
|
|
17
|
+
type LoadedPostcssOptions = Partial<Omit<Result, 'file'>>;
|
|
18
|
+
type CustomRuleCallback = (node: Rule, options: Readonly<UserDefinedPostcssOptions>) => void;
|
|
19
|
+
interface IPropValue {
|
|
20
|
+
prop: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
type CssPreflightOptions = {
|
|
24
|
+
[key: string]: string | number | boolean;
|
|
25
|
+
} | false;
|
|
26
|
+
type RequiredStyleHandlerOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* @description 默认为 true,此时会对样式主文件,进行猜测
|
|
29
|
+
*/
|
|
30
|
+
isMainChunk?: boolean;
|
|
31
|
+
cssPreflight?: CssPreflightOptions;
|
|
32
|
+
cssInjectPreflight?: InjectPreflight;
|
|
33
|
+
escapeMap?: Record<string, string>;
|
|
34
|
+
} & Pick<UserDefinedPostcssOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
|
|
35
|
+
interface InternalCssSelectorReplacerOptions {
|
|
36
|
+
mangleContext?: IMangleScopeContext;
|
|
37
|
+
escapeMap?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
type IStyleHandlerOptions = {
|
|
40
|
+
customRuleCallback?: CustomRuleCallback;
|
|
41
|
+
mangleContext?: IMangleScopeContext;
|
|
42
|
+
ctx?: IContext;
|
|
43
|
+
postcssOptions?: LoadedPostcssOptions;
|
|
44
|
+
cssRemoveHoverPseudoClass?: boolean;
|
|
45
|
+
cssPresetEnv?: pluginOptions;
|
|
46
|
+
} & RequiredStyleHandlerOptions;
|
|
47
|
+
interface UserDefinedPostcssOptions {
|
|
48
|
+
cssPreflight?: CssPreflightOptions;
|
|
49
|
+
cssPreflightRange?: 'all';
|
|
50
|
+
cssChildCombinatorReplaceValue?: string | string[];
|
|
51
|
+
cssPresetEnv?: pluginOptions;
|
|
52
|
+
injectAdditionalCssVarScope?: boolean;
|
|
53
|
+
cssSelectorReplacement?: {
|
|
54
|
+
root?: string | string[] | false;
|
|
55
|
+
universal?: string | string[] | false;
|
|
56
|
+
};
|
|
57
|
+
rem2rpx?: boolean | UserDefinedOptions;
|
|
58
|
+
postcssOptions?: LoadedPostcssOptions;
|
|
59
|
+
cssRemoveHoverPseudoClass?: boolean;
|
|
60
|
+
customRuleCallback?: CustomRuleCallback;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { type CustomRuleCallback as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type RequiredStyleHandlerOptions as R, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type IPropValue as b, createInjectPreflight as c, type CssPreflightOptions as d };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { IMangleScopeContext } from '@weapp-tailwindcss/mangle';
|
|
2
|
+
import { Rule } from 'postcss';
|
|
3
|
+
import { Result } from 'postcss-load-config';
|
|
4
|
+
import { pluginOptions } from 'postcss-preset-env';
|
|
5
|
+
import { UserDefinedOptions } from 'postcss-rem-to-responsive-pixel';
|
|
6
|
+
|
|
7
|
+
declare function createContext(): {
|
|
8
|
+
variablesScopeWeakMap: WeakMap<WeakKey, any>;
|
|
9
|
+
isVariablesScope: (rule: WeakKey) => boolean;
|
|
10
|
+
markVariablesScope: (rule: WeakKey) => void;
|
|
11
|
+
};
|
|
12
|
+
type IContext = ReturnType<typeof createContext>;
|
|
13
|
+
|
|
14
|
+
type InjectPreflight = () => IPropValue[];
|
|
15
|
+
declare function createInjectPreflight(options?: CssPreflightOptions): InjectPreflight;
|
|
16
|
+
|
|
17
|
+
type LoadedPostcssOptions = Partial<Omit<Result, 'file'>>;
|
|
18
|
+
type CustomRuleCallback = (node: Rule, options: Readonly<UserDefinedPostcssOptions>) => void;
|
|
19
|
+
interface IPropValue {
|
|
20
|
+
prop: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
type CssPreflightOptions = {
|
|
24
|
+
[key: string]: string | number | boolean;
|
|
25
|
+
} | false;
|
|
26
|
+
type RequiredStyleHandlerOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* @description 默认为 true,此时会对样式主文件,进行猜测
|
|
29
|
+
*/
|
|
30
|
+
isMainChunk?: boolean;
|
|
31
|
+
cssPreflight?: CssPreflightOptions;
|
|
32
|
+
cssInjectPreflight?: InjectPreflight;
|
|
33
|
+
escapeMap?: Record<string, string>;
|
|
34
|
+
} & Pick<UserDefinedPostcssOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
|
|
35
|
+
interface InternalCssSelectorReplacerOptions {
|
|
36
|
+
mangleContext?: IMangleScopeContext;
|
|
37
|
+
escapeMap?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
type IStyleHandlerOptions = {
|
|
40
|
+
customRuleCallback?: CustomRuleCallback;
|
|
41
|
+
mangleContext?: IMangleScopeContext;
|
|
42
|
+
ctx?: IContext;
|
|
43
|
+
postcssOptions?: LoadedPostcssOptions;
|
|
44
|
+
cssRemoveHoverPseudoClass?: boolean;
|
|
45
|
+
cssPresetEnv?: pluginOptions;
|
|
46
|
+
} & RequiredStyleHandlerOptions;
|
|
47
|
+
interface UserDefinedPostcssOptions {
|
|
48
|
+
cssPreflight?: CssPreflightOptions;
|
|
49
|
+
cssPreflightRange?: 'all';
|
|
50
|
+
cssChildCombinatorReplaceValue?: string | string[];
|
|
51
|
+
cssPresetEnv?: pluginOptions;
|
|
52
|
+
injectAdditionalCssVarScope?: boolean;
|
|
53
|
+
cssSelectorReplacement?: {
|
|
54
|
+
root?: string | string[] | false;
|
|
55
|
+
universal?: string | string[] | false;
|
|
56
|
+
};
|
|
57
|
+
rem2rpx?: boolean | UserDefinedOptions;
|
|
58
|
+
postcssOptions?: LoadedPostcssOptions;
|
|
59
|
+
cssRemoveHoverPseudoClass?: boolean;
|
|
60
|
+
customRuleCallback?: CustomRuleCallback;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { type CustomRuleCallback as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type RequiredStyleHandlerOptions as R, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type IPropValue as b, createInjectPreflight as c, type CssPreflightOptions as d };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import '@weapp-tailwindcss/mangle
|
|
1
|
+
import '@weapp-tailwindcss/mangle';
|
|
2
2
|
import 'postcss';
|
|
3
3
|
import 'postcss-load-config';
|
|
4
|
+
import 'postcss-preset-env';
|
|
4
5
|
import 'postcss-rem-to-responsive-pixel';
|
|
5
|
-
export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions } from './types-
|
|
6
|
+
export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions } from './types-DiXihH4o.mjs';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import '@weapp-tailwindcss/mangle
|
|
1
|
+
import '@weapp-tailwindcss/mangle';
|
|
2
2
|
import 'postcss';
|
|
3
3
|
import 'postcss-load-config';
|
|
4
|
+
import 'postcss-preset-env';
|
|
4
5
|
import 'postcss-rem-to-responsive-pixel';
|
|
5
|
-
export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions } from './types-
|
|
6
|
+
export { d as CssPreflightOptions, C as CustomRuleCallback, b as IPropValue, I as IStyleHandlerOptions, a as InternalCssSelectorReplacerOptions, L as LoadedPostcssOptions, R as RequiredStyleHandlerOptions, U as UserDefinedPostcssOptions } from './types-DiXihH4o.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/postcss",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "@weapp-tailwindcss/postcss",
|
|
5
5
|
"author": "ice breaker <1324318532@qq.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@weapp-core/escape": "~4.0.0",
|
|
37
|
-
"postcss": "~8.5.
|
|
37
|
+
"postcss": "~8.5.2",
|
|
38
38
|
"postcss-preset-env": "^10.1.3",
|
|
39
39
|
"postcss-rem-to-responsive-pixel": "~6.0.2",
|
|
40
|
-
"postcss-selector-parser": "~7.
|
|
41
|
-
"@weapp-tailwindcss/shared": "1.0.0
|
|
40
|
+
"postcss-selector-parser": "~7.1.0",
|
|
41
|
+
"@weapp-tailwindcss/shared": "1.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@weapp-tailwindcss/mangle": "1.0.0
|
|
44
|
+
"@weapp-tailwindcss/mangle": "1.0.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"dev": "tsup --watch --sourcemap",
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { IMangleScopeContext } from '@weapp-tailwindcss/mangle/types';
|
|
2
|
-
import { Rule } from 'postcss';
|
|
3
|
-
import { Result } from 'postcss-load-config';
|
|
4
|
-
import { UserDefinedOptions } from 'postcss-rem-to-responsive-pixel';
|
|
5
|
-
|
|
6
|
-
declare function createContext(): {
|
|
7
|
-
variablesScopeWeakMap: WeakMap<WeakKey, any>;
|
|
8
|
-
isVariablesScope: (rule: WeakKey) => boolean;
|
|
9
|
-
markVariablesScope: (rule: WeakKey) => void;
|
|
10
|
-
};
|
|
11
|
-
type IContext = ReturnType<typeof createContext>;
|
|
12
|
-
|
|
13
|
-
type InjectPreflight = () => IPropValue[];
|
|
14
|
-
declare function createInjectPreflight(options?: CssPreflightOptions): InjectPreflight;
|
|
15
|
-
|
|
16
|
-
type LoadedPostcssOptions = Partial<Omit<Result, 'file'>>;
|
|
17
|
-
type CustomRuleCallback = (node: Rule, options: Readonly<UserDefinedPostcssOptions>) => void;
|
|
18
|
-
interface IPropValue {
|
|
19
|
-
prop: string;
|
|
20
|
-
value: string;
|
|
21
|
-
}
|
|
22
|
-
type CssPreflightOptions = {
|
|
23
|
-
[key: string]: string | number | boolean;
|
|
24
|
-
} | false;
|
|
25
|
-
type RequiredStyleHandlerOptions = {
|
|
26
|
-
/**
|
|
27
|
-
* @description 默认为 true,此时会对样式主文件,进行猜测
|
|
28
|
-
*/
|
|
29
|
-
isMainChunk?: boolean;
|
|
30
|
-
cssInjectPreflight?: InjectPreflight;
|
|
31
|
-
escapeMap?: Record<string, string>;
|
|
32
|
-
} & Pick<UserDefinedPostcssOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
|
|
33
|
-
interface InternalCssSelectorReplacerOptions {
|
|
34
|
-
mangleContext?: IMangleScopeContext;
|
|
35
|
-
escapeMap?: Record<string, string>;
|
|
36
|
-
}
|
|
37
|
-
type IStyleHandlerOptions = {
|
|
38
|
-
customRuleCallback?: CustomRuleCallback;
|
|
39
|
-
mangleContext?: IMangleScopeContext;
|
|
40
|
-
ctx?: IContext;
|
|
41
|
-
postcssOptions?: LoadedPostcssOptions;
|
|
42
|
-
cssRemoveHoverPseudoClass?: boolean;
|
|
43
|
-
} & RequiredStyleHandlerOptions;
|
|
44
|
-
interface UserDefinedPostcssOptions {
|
|
45
|
-
/**
|
|
46
|
-
* @group 0.重要配置
|
|
47
|
-
* @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/7
|
|
48
|
-
* @description 在所有 view节点添加的 css 预设,可根据情况自由的禁用原先的规则,或者添加新的规则。默认预置 `css` 同 `tailwindcss` 类似,详细用法如下:
|
|
49
|
-
* ```js
|
|
50
|
-
* // default 默认,这代表会添加给所有的 view / text 元素, 受到 cssPreflightRange 配置项影响 :
|
|
51
|
-
cssPreflight: {
|
|
52
|
-
'box-sizing': 'border-box',
|
|
53
|
-
'border-width': '0',
|
|
54
|
-
'border-style': 'solid',
|
|
55
|
-
'border-color': 'currentColor'
|
|
56
|
-
}
|
|
57
|
-
// result
|
|
58
|
-
// box-sizing: border-box;
|
|
59
|
-
// border-width: 0;
|
|
60
|
-
// border-style: solid;
|
|
61
|
-
// border-color: currentColor
|
|
62
|
-
|
|
63
|
-
// case 禁用所有
|
|
64
|
-
cssPreflight: false
|
|
65
|
-
// result
|
|
66
|
-
// none
|
|
67
|
-
|
|
68
|
-
// case 禁用单个属性
|
|
69
|
-
cssPreflight: {
|
|
70
|
-
'box-sizing': false
|
|
71
|
-
}
|
|
72
|
-
// border-width: 0;
|
|
73
|
-
// border-style: solid;
|
|
74
|
-
// border-color: currentColor
|
|
75
|
-
|
|
76
|
-
// case 更改和添加单个属性
|
|
77
|
-
cssPreflight: {
|
|
78
|
-
'box-sizing': 'content-box',
|
|
79
|
-
'background': 'black'
|
|
80
|
-
}
|
|
81
|
-
// result
|
|
82
|
-
// box-sizing: content-box;
|
|
83
|
-
// border-width: 0;
|
|
84
|
-
// border-style: solid;
|
|
85
|
-
// border-color: currentColor;
|
|
86
|
-
// background: black
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
cssPreflight?: CssPreflightOptions;
|
|
90
|
-
/**
|
|
91
|
-
* @group 0.重要配置
|
|
92
|
-
* @issue https://github.com/sonofmagic/weapp-tailwindcss/pull/62
|
|
93
|
-
* @description 全局`dom`选择器,只有在这个选择器作用范围内的`dom`会被注入 `cssPreflight` 的变量和默认样式。只对所有的 `view`,`text` 和伪元素生效,想要对所有的元素生效,可切换为 `'all'`,此时需要自行处理和客户端默认样式的冲突
|
|
94
|
-
*/
|
|
95
|
-
cssPreflightRange?: 'all';
|
|
96
|
-
/**
|
|
97
|
-
* @group 3.一般配置
|
|
98
|
-
* @description 用于控制 tailwindcss 子组合器的生效标签范围, 这里我们用一个例子来说明这个配置是干啥用的.
|
|
99
|
-
*
|
|
100
|
-
* 我们布局的时候往往会使用 `space-x-4`
|
|
101
|
-
* 那么实际上会生成这样的css选择器:
|
|
102
|
-
* ```css
|
|
103
|
-
* .space-x-4>:not([hidden])~:not([hidden]){}
|
|
104
|
-
* ```
|
|
105
|
-
* 然而很不幸,这个选择器在小程序中是不支持的,写了会报错导致编译失败。
|
|
106
|
-
* 所以出于保守起见,我把它替换为了:
|
|
107
|
-
* ```css
|
|
108
|
-
* .space-x-4>view + view{}
|
|
109
|
-
* ```
|
|
110
|
-
* 这同时也是默认值, 而这个选项就允许你进行自定义子组合器的行为
|
|
111
|
-
*
|
|
112
|
-
* 你可以传入一个 字符串,或者字符串数组
|
|
113
|
-
* 1. 传入字符串数组,比如 `['view','text']` 生成:
|
|
114
|
-
* ```css
|
|
115
|
-
* .space-y-4>view + view,text + text{}
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* 2. 传入一个字符串,此时行为变成了整个替换,比如 `'view,text,button,input ~ view,text,button,input'` 生成:
|
|
119
|
-
* ```css
|
|
120
|
-
* .space-y-4>view,text,button,input ~ view,text,button,input{}
|
|
121
|
-
* ```
|
|
122
|
-
* @default 'view + view'
|
|
123
|
-
*/
|
|
124
|
-
cssChildCombinatorReplaceValue?: string | string[];
|
|
125
|
-
/**
|
|
126
|
-
* @group 0.重要配置
|
|
127
|
-
* @version `^2.6.0`
|
|
128
|
-
* @description 是否注入额外的 `tailwindcss css var scope` 区域,这个选项用于这样的场景
|
|
129
|
-
*
|
|
130
|
-
* 比如 `taro vue3` 使用 [NutUI](https://nutui.jd.com), 需要使用 `@tarojs/plugin-html`,而这个插件会启用 `postcss-html-transform` 从而移除所有带 `*` 选择器
|
|
131
|
-
*
|
|
132
|
-
* 这会导致 `tailwindcss css var scope` 区域被移除导致一些样式,比如渐变等等功能失效
|
|
133
|
-
*
|
|
134
|
-
* 这种场景下,启用这个选项会再次重新注入整个 `tailwindcss css var scope`
|
|
135
|
-
*
|
|
136
|
-
* @default false
|
|
137
|
-
*/
|
|
138
|
-
injectAdditionalCssVarScope?: boolean;
|
|
139
|
-
/**
|
|
140
|
-
* @group 0.重要配置
|
|
141
|
-
* @description 用于处理 css 选择器的替换规则
|
|
142
|
-
*/
|
|
143
|
-
cssSelectorReplacement?: {
|
|
144
|
-
/**
|
|
145
|
-
* @default `'page'` <br/>
|
|
146
|
-
* @description 把`css`中的全局选择器 **`:root`** 替换为指定值,默认替换为 `'page'`,设置为 `false` 时不进行替换
|
|
147
|
-
*/
|
|
148
|
-
root?: string | string[] | false;
|
|
149
|
-
/**
|
|
150
|
-
* @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/81 <br/>
|
|
151
|
-
* @default `['view','text']` <br/>
|
|
152
|
-
* @description 把`css`中的全局选择器 **`*`** 替换为指定值,默认替换为 `'view','text'`,设置为 `false` 时不进行替换,此时小程序会由于不认识`*`选择器而报错
|
|
153
|
-
*/
|
|
154
|
-
universal?: string | string[] | false;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* @version `^3.0.0`
|
|
158
|
-
* @group 0.重要配置
|
|
159
|
-
* @description rem 转 rpx 配置,默认为 `undefined` 不开启,可传入 `true` 启用默认配置项,也可传入自定义配置项,配置项列表见 [postcss-rem-to-responsive-pixel](https://www.npmjs.com/package/postcss-rem-to-responsive-pixel)
|
|
160
|
-
*/
|
|
161
|
-
rem2rpx?: boolean | UserDefinedOptions;
|
|
162
|
-
/**
|
|
163
|
-
* @version `^3.2.0`
|
|
164
|
-
* @group 3.一般配置
|
|
165
|
-
* @description 对解析 css 使用的 `postcss` 工具的配置
|
|
166
|
-
*/
|
|
167
|
-
postcssOptions?: LoadedPostcssOptions;
|
|
168
|
-
/**
|
|
169
|
-
* @version `^3.2.1`
|
|
170
|
-
* @group 3.一般配置
|
|
171
|
-
* @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/293
|
|
172
|
-
* @default `true`
|
|
173
|
-
* @description 是否删除 css :hover 选择器节点,默认为 `true`, 原因在于,小程序 css :hover 是不生效的,要使用 view 这种标签的 hover-class 属性
|
|
174
|
-
*/
|
|
175
|
-
cssRemoveHoverPseudoClass?: boolean;
|
|
176
|
-
/**
|
|
177
|
-
* @group 3.一般配置
|
|
178
|
-
* @description 用于自定义处理 css 的回调函数,可根据 Postcss walk 方法自由定制处理方案的 callback 方法
|
|
179
|
-
*/
|
|
180
|
-
customRuleCallback?: CustomRuleCallback;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export { type CustomRuleCallback as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type RequiredStyleHandlerOptions as R, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type IPropValue as b, createInjectPreflight as c, type CssPreflightOptions as d };
|
package/dist/types-BlpvjUzB.d.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { IMangleScopeContext } from '@weapp-tailwindcss/mangle/types';
|
|
2
|
-
import { Rule } from 'postcss';
|
|
3
|
-
import { Result } from 'postcss-load-config';
|
|
4
|
-
import { UserDefinedOptions } from 'postcss-rem-to-responsive-pixel';
|
|
5
|
-
|
|
6
|
-
declare function createContext(): {
|
|
7
|
-
variablesScopeWeakMap: WeakMap<WeakKey, any>;
|
|
8
|
-
isVariablesScope: (rule: WeakKey) => boolean;
|
|
9
|
-
markVariablesScope: (rule: WeakKey) => void;
|
|
10
|
-
};
|
|
11
|
-
type IContext = ReturnType<typeof createContext>;
|
|
12
|
-
|
|
13
|
-
type InjectPreflight = () => IPropValue[];
|
|
14
|
-
declare function createInjectPreflight(options?: CssPreflightOptions): InjectPreflight;
|
|
15
|
-
|
|
16
|
-
type LoadedPostcssOptions = Partial<Omit<Result, 'file'>>;
|
|
17
|
-
type CustomRuleCallback = (node: Rule, options: Readonly<UserDefinedPostcssOptions>) => void;
|
|
18
|
-
interface IPropValue {
|
|
19
|
-
prop: string;
|
|
20
|
-
value: string;
|
|
21
|
-
}
|
|
22
|
-
type CssPreflightOptions = {
|
|
23
|
-
[key: string]: string | number | boolean;
|
|
24
|
-
} | false;
|
|
25
|
-
type RequiredStyleHandlerOptions = {
|
|
26
|
-
/**
|
|
27
|
-
* @description 默认为 true,此时会对样式主文件,进行猜测
|
|
28
|
-
*/
|
|
29
|
-
isMainChunk?: boolean;
|
|
30
|
-
cssInjectPreflight?: InjectPreflight;
|
|
31
|
-
escapeMap?: Record<string, string>;
|
|
32
|
-
} & Pick<UserDefinedPostcssOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
|
|
33
|
-
interface InternalCssSelectorReplacerOptions {
|
|
34
|
-
mangleContext?: IMangleScopeContext;
|
|
35
|
-
escapeMap?: Record<string, string>;
|
|
36
|
-
}
|
|
37
|
-
type IStyleHandlerOptions = {
|
|
38
|
-
customRuleCallback?: CustomRuleCallback;
|
|
39
|
-
mangleContext?: IMangleScopeContext;
|
|
40
|
-
ctx?: IContext;
|
|
41
|
-
postcssOptions?: LoadedPostcssOptions;
|
|
42
|
-
cssRemoveHoverPseudoClass?: boolean;
|
|
43
|
-
} & RequiredStyleHandlerOptions;
|
|
44
|
-
interface UserDefinedPostcssOptions {
|
|
45
|
-
/**
|
|
46
|
-
* @group 0.重要配置
|
|
47
|
-
* @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/7
|
|
48
|
-
* @description 在所有 view节点添加的 css 预设,可根据情况自由的禁用原先的规则,或者添加新的规则。默认预置 `css` 同 `tailwindcss` 类似,详细用法如下:
|
|
49
|
-
* ```js
|
|
50
|
-
* // default 默认,这代表会添加给所有的 view / text 元素, 受到 cssPreflightRange 配置项影响 :
|
|
51
|
-
cssPreflight: {
|
|
52
|
-
'box-sizing': 'border-box',
|
|
53
|
-
'border-width': '0',
|
|
54
|
-
'border-style': 'solid',
|
|
55
|
-
'border-color': 'currentColor'
|
|
56
|
-
}
|
|
57
|
-
// result
|
|
58
|
-
// box-sizing: border-box;
|
|
59
|
-
// border-width: 0;
|
|
60
|
-
// border-style: solid;
|
|
61
|
-
// border-color: currentColor
|
|
62
|
-
|
|
63
|
-
// case 禁用所有
|
|
64
|
-
cssPreflight: false
|
|
65
|
-
// result
|
|
66
|
-
// none
|
|
67
|
-
|
|
68
|
-
// case 禁用单个属性
|
|
69
|
-
cssPreflight: {
|
|
70
|
-
'box-sizing': false
|
|
71
|
-
}
|
|
72
|
-
// border-width: 0;
|
|
73
|
-
// border-style: solid;
|
|
74
|
-
// border-color: currentColor
|
|
75
|
-
|
|
76
|
-
// case 更改和添加单个属性
|
|
77
|
-
cssPreflight: {
|
|
78
|
-
'box-sizing': 'content-box',
|
|
79
|
-
'background': 'black'
|
|
80
|
-
}
|
|
81
|
-
// result
|
|
82
|
-
// box-sizing: content-box;
|
|
83
|
-
// border-width: 0;
|
|
84
|
-
// border-style: solid;
|
|
85
|
-
// border-color: currentColor;
|
|
86
|
-
// background: black
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
cssPreflight?: CssPreflightOptions;
|
|
90
|
-
/**
|
|
91
|
-
* @group 0.重要配置
|
|
92
|
-
* @issue https://github.com/sonofmagic/weapp-tailwindcss/pull/62
|
|
93
|
-
* @description 全局`dom`选择器,只有在这个选择器作用范围内的`dom`会被注入 `cssPreflight` 的变量和默认样式。只对所有的 `view`,`text` 和伪元素生效,想要对所有的元素生效,可切换为 `'all'`,此时需要自行处理和客户端默认样式的冲突
|
|
94
|
-
*/
|
|
95
|
-
cssPreflightRange?: 'all';
|
|
96
|
-
/**
|
|
97
|
-
* @group 3.一般配置
|
|
98
|
-
* @description 用于控制 tailwindcss 子组合器的生效标签范围, 这里我们用一个例子来说明这个配置是干啥用的.
|
|
99
|
-
*
|
|
100
|
-
* 我们布局的时候往往会使用 `space-x-4`
|
|
101
|
-
* 那么实际上会生成这样的css选择器:
|
|
102
|
-
* ```css
|
|
103
|
-
* .space-x-4>:not([hidden])~:not([hidden]){}
|
|
104
|
-
* ```
|
|
105
|
-
* 然而很不幸,这个选择器在小程序中是不支持的,写了会报错导致编译失败。
|
|
106
|
-
* 所以出于保守起见,我把它替换为了:
|
|
107
|
-
* ```css
|
|
108
|
-
* .space-x-4>view + view{}
|
|
109
|
-
* ```
|
|
110
|
-
* 这同时也是默认值, 而这个选项就允许你进行自定义子组合器的行为
|
|
111
|
-
*
|
|
112
|
-
* 你可以传入一个 字符串,或者字符串数组
|
|
113
|
-
* 1. 传入字符串数组,比如 `['view','text']` 生成:
|
|
114
|
-
* ```css
|
|
115
|
-
* .space-y-4>view + view,text + text{}
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* 2. 传入一个字符串,此时行为变成了整个替换,比如 `'view,text,button,input ~ view,text,button,input'` 生成:
|
|
119
|
-
* ```css
|
|
120
|
-
* .space-y-4>view,text,button,input ~ view,text,button,input{}
|
|
121
|
-
* ```
|
|
122
|
-
* @default 'view + view'
|
|
123
|
-
*/
|
|
124
|
-
cssChildCombinatorReplaceValue?: string | string[];
|
|
125
|
-
/**
|
|
126
|
-
* @group 0.重要配置
|
|
127
|
-
* @version `^2.6.0`
|
|
128
|
-
* @description 是否注入额外的 `tailwindcss css var scope` 区域,这个选项用于这样的场景
|
|
129
|
-
*
|
|
130
|
-
* 比如 `taro vue3` 使用 [NutUI](https://nutui.jd.com), 需要使用 `@tarojs/plugin-html`,而这个插件会启用 `postcss-html-transform` 从而移除所有带 `*` 选择器
|
|
131
|
-
*
|
|
132
|
-
* 这会导致 `tailwindcss css var scope` 区域被移除导致一些样式,比如渐变等等功能失效
|
|
133
|
-
*
|
|
134
|
-
* 这种场景下,启用这个选项会再次重新注入整个 `tailwindcss css var scope`
|
|
135
|
-
*
|
|
136
|
-
* @default false
|
|
137
|
-
*/
|
|
138
|
-
injectAdditionalCssVarScope?: boolean;
|
|
139
|
-
/**
|
|
140
|
-
* @group 0.重要配置
|
|
141
|
-
* @description 用于处理 css 选择器的替换规则
|
|
142
|
-
*/
|
|
143
|
-
cssSelectorReplacement?: {
|
|
144
|
-
/**
|
|
145
|
-
* @default `'page'` <br/>
|
|
146
|
-
* @description 把`css`中的全局选择器 **`:root`** 替换为指定值,默认替换为 `'page'`,设置为 `false` 时不进行替换
|
|
147
|
-
*/
|
|
148
|
-
root?: string | string[] | false;
|
|
149
|
-
/**
|
|
150
|
-
* @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/81 <br/>
|
|
151
|
-
* @default `['view','text']` <br/>
|
|
152
|
-
* @description 把`css`中的全局选择器 **`*`** 替换为指定值,默认替换为 `'view','text'`,设置为 `false` 时不进行替换,此时小程序会由于不认识`*`选择器而报错
|
|
153
|
-
*/
|
|
154
|
-
universal?: string | string[] | false;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* @version `^3.0.0`
|
|
158
|
-
* @group 0.重要配置
|
|
159
|
-
* @description rem 转 rpx 配置,默认为 `undefined` 不开启,可传入 `true` 启用默认配置项,也可传入自定义配置项,配置项列表见 [postcss-rem-to-responsive-pixel](https://www.npmjs.com/package/postcss-rem-to-responsive-pixel)
|
|
160
|
-
*/
|
|
161
|
-
rem2rpx?: boolean | UserDefinedOptions;
|
|
162
|
-
/**
|
|
163
|
-
* @version `^3.2.0`
|
|
164
|
-
* @group 3.一般配置
|
|
165
|
-
* @description 对解析 css 使用的 `postcss` 工具的配置
|
|
166
|
-
*/
|
|
167
|
-
postcssOptions?: LoadedPostcssOptions;
|
|
168
|
-
/**
|
|
169
|
-
* @version `^3.2.1`
|
|
170
|
-
* @group 3.一般配置
|
|
171
|
-
* @issue https://github.com/sonofmagic/weapp-tailwindcss/issues/293
|
|
172
|
-
* @default `true`
|
|
173
|
-
* @description 是否删除 css :hover 选择器节点,默认为 `true`, 原因在于,小程序 css :hover 是不生效的,要使用 view 这种标签的 hover-class 属性
|
|
174
|
-
*/
|
|
175
|
-
cssRemoveHoverPseudoClass?: boolean;
|
|
176
|
-
/**
|
|
177
|
-
* @group 3.一般配置
|
|
178
|
-
* @description 用于自定义处理 css 的回调函数,可根据 Postcss walk 方法自由定制处理方案的 callback 方法
|
|
179
|
-
*/
|
|
180
|
-
customRuleCallback?: CustomRuleCallback;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export { type CustomRuleCallback as C, type IStyleHandlerOptions as I, type LoadedPostcssOptions as L, type RequiredStyleHandlerOptions as R, type UserDefinedPostcssOptions as U, type InternalCssSelectorReplacerOptions as a, type IPropValue as b, createInjectPreflight as c, type CssPreflightOptions as d };
|