@tailwindcss-mangle/config 5.1.2 → 6.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.cjs CHANGED
@@ -33,8 +33,8 @@ __export(index_exports, {
33
33
  CONFIG_NAME: () => CONFIG_NAME,
34
34
  defineConfig: () => defineConfig,
35
35
  getConfig: () => getConfig,
36
- getDefaultMangleUserConfig: () => getDefaultMangleUserConfig,
37
- getDefaultPatchConfig: () => getDefaultPatchConfig,
36
+ getDefaultRegistryConfig: () => getDefaultRegistryConfig,
37
+ getDefaultTransformerConfig: () => getDefaultTransformerConfig,
38
38
  getDefaultUserConfig: () => getDefaultUserConfig,
39
39
  initConfig: () => initConfig
40
40
  });
@@ -57,35 +57,42 @@ var defaultPipelineInclude = [
57
57
  import_is_css_request.CSS_LANGS_RE
58
58
  ];
59
59
  var defaultPipelineExclude = [];
60
- function getDefaultPatchConfig() {
60
+ function getDefaultRegistryConfig() {
61
61
  return {
62
62
  output: {
63
- filename: ".tw-patch/tw-class-list.json",
64
- removeUniversalSelector: true,
65
- loose: true
63
+ file: ".tw-patch/tw-class-list.json",
64
+ stripUniversalSelector: true,
65
+ pretty: true
66
66
  },
67
- tailwindcss: {}
67
+ tailwind: {}
68
68
  };
69
69
  }
70
- function getDefaultMangleUserConfig() {
70
+ function getDefaultTransformerConfig() {
71
71
  return {
72
- mangleClassFilter: import_shared.defaultMangleClassFilter,
73
- include: defaultPipelineInclude,
74
- exclude: defaultPipelineExclude,
72
+ filter: import_shared.defaultMangleClassFilter,
73
+ sources: {
74
+ include: defaultPipelineInclude,
75
+ exclude: defaultPipelineExclude
76
+ },
75
77
  disabled: import_node_process.default.env.NODE_ENV === "development",
76
- classListPath: ".tw-patch/tw-class-list.json",
77
- classMapOutput: {
78
- enable: false,
79
- filename: ".tw-patch/tw-map-list.json",
80
- loose: true
78
+ registry: {
79
+ file: ".tw-patch/tw-class-list.json",
80
+ mapping: {
81
+ enabled: false,
82
+ file: ".tw-patch/tw-map-list.json",
83
+ loose: true
84
+ }
81
85
  },
82
- preserveFunction: []
86
+ preserve: {
87
+ functions: [],
88
+ classes: []
89
+ }
83
90
  };
84
91
  }
85
92
  function getDefaultUserConfig() {
86
93
  return {
87
- patch: getDefaultPatchConfig(),
88
- mangle: getDefaultMangleUserConfig()
94
+ registry: getDefaultRegistryConfig(),
95
+ transformer: getDefaultTransformerConfig()
89
96
  };
90
97
  }
91
98
 
@@ -105,7 +112,18 @@ function initConfig(cwd) {
105
112
  import_pathe.default.resolve(cwd, `${CONFIG_NAME}.config.ts`),
106
113
  `import { defineConfig } from 'tailwindcss-patch'
107
114
 
108
- export default defineConfig({})
115
+ export default defineConfig({
116
+ registry: {
117
+ output: {
118
+ file: '.tw-patch/tw-class-list.json',
119
+ },
120
+ },
121
+ transformer: {
122
+ registry: {
123
+ file: '.tw-patch/tw-class-list.json',
124
+ },
125
+ },
126
+ })
109
127
  `,
110
128
  "utf8"
111
129
  );
@@ -115,8 +133,8 @@ export default defineConfig({})
115
133
  CONFIG_NAME,
116
134
  defineConfig,
117
135
  getConfig,
118
- getDefaultMangleUserConfig,
119
- getDefaultPatchConfig,
136
+ getDefaultRegistryConfig,
137
+ getDefaultTransformerConfig,
120
138
  getDefaultUserConfig,
121
139
  initConfig
122
140
  });
package/dist/index.d.cts CHANGED
@@ -4,73 +4,80 @@ import { IClassGeneratorOptions } from '@tailwindcss-mangle/shared';
4
4
  import { SourceEntry } from '@tailwindcss/oxide';
5
5
  import { PackageResolvingOptions } from 'local-pkg';
6
6
 
7
- interface ClassMapOutputOptions {
8
- enable?: boolean;
9
- filename?: string;
7
+ interface TransformerMappingConfig {
8
+ enabled?: boolean;
9
+ file?: string;
10
10
  loose?: boolean;
11
11
  }
12
- interface ClassMapOutputItem {
13
- before: string;
14
- after: string;
12
+ interface TransformerMappingEntry {
13
+ original: string;
14
+ mangled: string;
15
15
  usedBy: string[];
16
16
  }
17
- interface MangleUserConfig {
18
- mangleClassFilter?: (className: string) => boolean;
19
- classGenerator?: IClassGeneratorOptions;
20
- exclude?: FilterPattern;
17
+ type TransformerMappingOption = boolean | TransformerMappingConfig | ((entries: TransformerMappingEntry[]) => void);
18
+ interface TransformerRegistryOptions {
19
+ file?: string;
20
+ mapping?: TransformerMappingOption;
21
+ }
22
+ interface TransformerSourceOptions {
21
23
  include?: FilterPattern;
22
- classListPath?: string;
23
- classMapOutput?: boolean | ClassMapOutputOptions | ((json: ClassMapOutputItem[]) => void);
24
- disabled?: boolean;
25
- preserveFunction?: string[];
24
+ exclude?: FilterPattern;
26
25
  }
27
- interface TailwindcssV2PatchConfig {
28
- cwd?: string;
29
- config?: string;
26
+ interface TransformerPreserveOptions {
27
+ functions?: string[];
28
+ classes?: string[];
30
29
  }
31
- interface TailwindcssV3PatchConfig {
30
+ interface TransformerOptions {
31
+ disabled?: boolean;
32
+ filter?: (className: string) => boolean;
33
+ generator?: IClassGeneratorOptions;
34
+ sources?: TransformerSourceOptions;
35
+ registry?: TransformerRegistryOptions;
36
+ preserve?: TransformerPreserveOptions;
37
+ }
38
+ interface TailwindLocatorOptions {
32
39
  cwd?: string;
33
40
  config?: string;
34
41
  }
35
- interface TailwindcssV4PatchConfig {
42
+ interface TailwindNextOptions {
36
43
  sources?: SourceEntry[];
37
44
  base?: string;
38
45
  css?: string;
39
46
  cssEntries?: string[];
40
47
  }
41
- interface TailwindcssUserConfig {
48
+ interface TailwindTargetOptions {
42
49
  version?: 2 | 3 | 4;
43
- v2?: TailwindcssV2PatchConfig;
44
- v3?: TailwindcssV3PatchConfig;
45
- v4?: TailwindcssV4PatchConfig;
50
+ package?: string;
51
+ resolve?: PackageResolvingOptions;
52
+ legacy?: TailwindLocatorOptions;
53
+ classic?: TailwindLocatorOptions;
54
+ next?: TailwindNextOptions;
55
+ cwd?: string;
56
+ config?: string;
46
57
  }
47
- interface OutputUserConfig {
48
- filename?: string;
49
- loose?: boolean;
50
- /**
51
- * @description remove * in output json
52
- */
53
- removeUniversalSelector?: boolean;
58
+ interface RegistryOutputOptions {
59
+ file?: string;
60
+ pretty?: boolean | number;
61
+ stripUniversalSelector?: boolean;
54
62
  }
55
- interface PatchUserConfig {
56
- packageName?: string;
57
- output?: OutputUserConfig;
58
- tailwindcss?: TailwindcssUserConfig;
59
- resolve?: PackageResolvingOptions;
63
+ interface RegistryOptions {
64
+ output?: RegistryOutputOptions;
65
+ tailwind?: TailwindTargetOptions;
60
66
  }
61
- interface UserConfig {
62
- patch?: PatchUserConfig;
63
- mangle?: MangleUserConfig;
67
+ interface TailwindcssMangleConfig {
68
+ registry?: RegistryOptions;
69
+ transformer?: TransformerOptions;
64
70
  }
71
+ type UserConfig = TailwindcssMangleConfig;
65
72
 
66
- declare function getConfig(cwd?: string): Promise<c12.ResolvedConfig<UserConfig, c12.ConfigLayerMeta>>;
67
- declare const defineConfig: c12.DefineConfig<UserConfig, c12.ConfigLayerMeta>;
73
+ declare function getConfig(cwd?: string): Promise<c12.ResolvedConfig<TailwindcssMangleConfig, c12.ConfigLayerMeta>>;
74
+ declare const defineConfig: c12.DefineConfig<TailwindcssMangleConfig, c12.ConfigLayerMeta>;
68
75
  declare function initConfig(cwd: string): Promise<void>;
69
76
 
70
77
  declare const CONFIG_NAME = "tailwindcss-mangle";
71
78
 
72
- declare function getDefaultPatchConfig(): PatchUserConfig;
73
- declare function getDefaultMangleUserConfig(): MangleUserConfig;
74
- declare function getDefaultUserConfig(): UserConfig;
79
+ declare function getDefaultRegistryConfig(): RegistryOptions;
80
+ declare function getDefaultTransformerConfig(): TransformerOptions;
81
+ declare function getDefaultUserConfig(): TailwindcssMangleConfig;
75
82
 
76
- export { CONFIG_NAME, type ClassMapOutputItem, type ClassMapOutputOptions, type MangleUserConfig, type OutputUserConfig, type PatchUserConfig, type TailwindcssUserConfig, type TailwindcssV2PatchConfig, type TailwindcssV3PatchConfig, type TailwindcssV4PatchConfig, type UserConfig, defineConfig, getConfig, getDefaultMangleUserConfig, getDefaultPatchConfig, getDefaultUserConfig, initConfig };
83
+ export { CONFIG_NAME, type RegistryOptions, type RegistryOutputOptions, type TailwindLocatorOptions, type TailwindNextOptions, type TailwindTargetOptions, type TailwindcssMangleConfig, type TransformerMappingConfig, type TransformerMappingEntry, type TransformerMappingOption, type TransformerOptions, type TransformerPreserveOptions, type TransformerRegistryOptions, type TransformerSourceOptions, type UserConfig, defineConfig, getConfig, getDefaultRegistryConfig, getDefaultTransformerConfig, getDefaultUserConfig, initConfig };
package/dist/index.d.ts CHANGED
@@ -4,73 +4,80 @@ import { IClassGeneratorOptions } from '@tailwindcss-mangle/shared';
4
4
  import { SourceEntry } from '@tailwindcss/oxide';
5
5
  import { PackageResolvingOptions } from 'local-pkg';
6
6
 
7
- interface ClassMapOutputOptions {
8
- enable?: boolean;
9
- filename?: string;
7
+ interface TransformerMappingConfig {
8
+ enabled?: boolean;
9
+ file?: string;
10
10
  loose?: boolean;
11
11
  }
12
- interface ClassMapOutputItem {
13
- before: string;
14
- after: string;
12
+ interface TransformerMappingEntry {
13
+ original: string;
14
+ mangled: string;
15
15
  usedBy: string[];
16
16
  }
17
- interface MangleUserConfig {
18
- mangleClassFilter?: (className: string) => boolean;
19
- classGenerator?: IClassGeneratorOptions;
20
- exclude?: FilterPattern;
17
+ type TransformerMappingOption = boolean | TransformerMappingConfig | ((entries: TransformerMappingEntry[]) => void);
18
+ interface TransformerRegistryOptions {
19
+ file?: string;
20
+ mapping?: TransformerMappingOption;
21
+ }
22
+ interface TransformerSourceOptions {
21
23
  include?: FilterPattern;
22
- classListPath?: string;
23
- classMapOutput?: boolean | ClassMapOutputOptions | ((json: ClassMapOutputItem[]) => void);
24
- disabled?: boolean;
25
- preserveFunction?: string[];
24
+ exclude?: FilterPattern;
26
25
  }
27
- interface TailwindcssV2PatchConfig {
28
- cwd?: string;
29
- config?: string;
26
+ interface TransformerPreserveOptions {
27
+ functions?: string[];
28
+ classes?: string[];
30
29
  }
31
- interface TailwindcssV3PatchConfig {
30
+ interface TransformerOptions {
31
+ disabled?: boolean;
32
+ filter?: (className: string) => boolean;
33
+ generator?: IClassGeneratorOptions;
34
+ sources?: TransformerSourceOptions;
35
+ registry?: TransformerRegistryOptions;
36
+ preserve?: TransformerPreserveOptions;
37
+ }
38
+ interface TailwindLocatorOptions {
32
39
  cwd?: string;
33
40
  config?: string;
34
41
  }
35
- interface TailwindcssV4PatchConfig {
42
+ interface TailwindNextOptions {
36
43
  sources?: SourceEntry[];
37
44
  base?: string;
38
45
  css?: string;
39
46
  cssEntries?: string[];
40
47
  }
41
- interface TailwindcssUserConfig {
48
+ interface TailwindTargetOptions {
42
49
  version?: 2 | 3 | 4;
43
- v2?: TailwindcssV2PatchConfig;
44
- v3?: TailwindcssV3PatchConfig;
45
- v4?: TailwindcssV4PatchConfig;
50
+ package?: string;
51
+ resolve?: PackageResolvingOptions;
52
+ legacy?: TailwindLocatorOptions;
53
+ classic?: TailwindLocatorOptions;
54
+ next?: TailwindNextOptions;
55
+ cwd?: string;
56
+ config?: string;
46
57
  }
47
- interface OutputUserConfig {
48
- filename?: string;
49
- loose?: boolean;
50
- /**
51
- * @description remove * in output json
52
- */
53
- removeUniversalSelector?: boolean;
58
+ interface RegistryOutputOptions {
59
+ file?: string;
60
+ pretty?: boolean | number;
61
+ stripUniversalSelector?: boolean;
54
62
  }
55
- interface PatchUserConfig {
56
- packageName?: string;
57
- output?: OutputUserConfig;
58
- tailwindcss?: TailwindcssUserConfig;
59
- resolve?: PackageResolvingOptions;
63
+ interface RegistryOptions {
64
+ output?: RegistryOutputOptions;
65
+ tailwind?: TailwindTargetOptions;
60
66
  }
61
- interface UserConfig {
62
- patch?: PatchUserConfig;
63
- mangle?: MangleUserConfig;
67
+ interface TailwindcssMangleConfig {
68
+ registry?: RegistryOptions;
69
+ transformer?: TransformerOptions;
64
70
  }
71
+ type UserConfig = TailwindcssMangleConfig;
65
72
 
66
- declare function getConfig(cwd?: string): Promise<c12.ResolvedConfig<UserConfig, c12.ConfigLayerMeta>>;
67
- declare const defineConfig: c12.DefineConfig<UserConfig, c12.ConfigLayerMeta>;
73
+ declare function getConfig(cwd?: string): Promise<c12.ResolvedConfig<TailwindcssMangleConfig, c12.ConfigLayerMeta>>;
74
+ declare const defineConfig: c12.DefineConfig<TailwindcssMangleConfig, c12.ConfigLayerMeta>;
68
75
  declare function initConfig(cwd: string): Promise<void>;
69
76
 
70
77
  declare const CONFIG_NAME = "tailwindcss-mangle";
71
78
 
72
- declare function getDefaultPatchConfig(): PatchUserConfig;
73
- declare function getDefaultMangleUserConfig(): MangleUserConfig;
74
- declare function getDefaultUserConfig(): UserConfig;
79
+ declare function getDefaultRegistryConfig(): RegistryOptions;
80
+ declare function getDefaultTransformerConfig(): TransformerOptions;
81
+ declare function getDefaultUserConfig(): TailwindcssMangleConfig;
75
82
 
76
- export { CONFIG_NAME, type ClassMapOutputItem, type ClassMapOutputOptions, type MangleUserConfig, type OutputUserConfig, type PatchUserConfig, type TailwindcssUserConfig, type TailwindcssV2PatchConfig, type TailwindcssV3PatchConfig, type TailwindcssV4PatchConfig, type UserConfig, defineConfig, getConfig, getDefaultMangleUserConfig, getDefaultPatchConfig, getDefaultUserConfig, initConfig };
83
+ export { CONFIG_NAME, type RegistryOptions, type RegistryOutputOptions, type TailwindLocatorOptions, type TailwindNextOptions, type TailwindTargetOptions, type TailwindcssMangleConfig, type TransformerMappingConfig, type TransformerMappingEntry, type TransformerMappingOption, type TransformerOptions, type TransformerPreserveOptions, type TransformerRegistryOptions, type TransformerSourceOptions, type UserConfig, defineConfig, getConfig, getDefaultRegistryConfig, getDefaultTransformerConfig, getDefaultUserConfig, initConfig };
package/dist/index.js CHANGED
@@ -15,35 +15,42 @@ var defaultPipelineInclude = [
15
15
  CSS_LANGS_RE
16
16
  ];
17
17
  var defaultPipelineExclude = [];
18
- function getDefaultPatchConfig() {
18
+ function getDefaultRegistryConfig() {
19
19
  return {
20
20
  output: {
21
- filename: ".tw-patch/tw-class-list.json",
22
- removeUniversalSelector: true,
23
- loose: true
21
+ file: ".tw-patch/tw-class-list.json",
22
+ stripUniversalSelector: true,
23
+ pretty: true
24
24
  },
25
- tailwindcss: {}
25
+ tailwind: {}
26
26
  };
27
27
  }
28
- function getDefaultMangleUserConfig() {
28
+ function getDefaultTransformerConfig() {
29
29
  return {
30
- mangleClassFilter: defaultMangleClassFilter,
31
- include: defaultPipelineInclude,
32
- exclude: defaultPipelineExclude,
30
+ filter: defaultMangleClassFilter,
31
+ sources: {
32
+ include: defaultPipelineInclude,
33
+ exclude: defaultPipelineExclude
34
+ },
33
35
  disabled: process.env.NODE_ENV === "development",
34
- classListPath: ".tw-patch/tw-class-list.json",
35
- classMapOutput: {
36
- enable: false,
37
- filename: ".tw-patch/tw-map-list.json",
38
- loose: true
36
+ registry: {
37
+ file: ".tw-patch/tw-class-list.json",
38
+ mapping: {
39
+ enabled: false,
40
+ file: ".tw-patch/tw-map-list.json",
41
+ loose: true
42
+ }
39
43
  },
40
- preserveFunction: []
44
+ preserve: {
45
+ functions: [],
46
+ classes: []
47
+ }
41
48
  };
42
49
  }
43
50
  function getDefaultUserConfig() {
44
51
  return {
45
- patch: getDefaultPatchConfig(),
46
- mangle: getDefaultMangleUserConfig()
52
+ registry: getDefaultRegistryConfig(),
53
+ transformer: getDefaultTransformerConfig()
47
54
  };
48
55
  }
49
56
 
@@ -63,7 +70,18 @@ function initConfig(cwd) {
63
70
  path.resolve(cwd, `${CONFIG_NAME}.config.ts`),
64
71
  `import { defineConfig } from 'tailwindcss-patch'
65
72
 
66
- export default defineConfig({})
73
+ export default defineConfig({
74
+ registry: {
75
+ output: {
76
+ file: '.tw-patch/tw-class-list.json',
77
+ },
78
+ },
79
+ transformer: {
80
+ registry: {
81
+ file: '.tw-patch/tw-class-list.json',
82
+ },
83
+ },
84
+ })
67
85
  `,
68
86
  "utf8"
69
87
  );
@@ -72,8 +90,8 @@ export {
72
90
  CONFIG_NAME,
73
91
  defineConfig,
74
92
  getConfig,
75
- getDefaultMangleUserConfig,
76
- getDefaultPatchConfig,
93
+ getDefaultRegistryConfig,
94
+ getDefaultTransformerConfig,
77
95
  getDefaultUserConfig,
78
96
  initConfig
79
97
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tailwindcss-mangle/config",
3
3
  "type": "module",
4
- "version": "5.1.2",
4
+ "version": "6.0.0",
5
5
  "description": "The config and load function of tailwindcss-mangle",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -49,7 +49,7 @@
49
49
  "registry": "https://registry.npmjs.org/"
50
50
  },
51
51
  "dependencies": {
52
- "c12": "^2.0.4",
52
+ "c12": "^3.3.1",
53
53
  "fs-extra": "^11.3.2",
54
54
  "is-css-request": "^1.0.1",
55
55
  "pathe": "^2.0.3",