@tailwindcss-mangle/config 5.1.2 → 6.0.1

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,15 +33,14 @@ __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
  });
41
41
  module.exports = __toCommonJS(index_exports);
42
42
 
43
43
  // src/config.ts
44
- var import_c12 = require("c12");
45
44
  var import_fs_extra = __toESM(require("fs-extra"), 1);
46
45
  var import_pathe = __toESM(require("pathe"), 1);
47
46
 
@@ -57,41 +56,56 @@ var defaultPipelineInclude = [
57
56
  import_is_css_request.CSS_LANGS_RE
58
57
  ];
59
58
  var defaultPipelineExclude = [];
60
- function getDefaultPatchConfig() {
59
+ function getDefaultRegistryConfig() {
61
60
  return {
62
61
  output: {
63
- filename: ".tw-patch/tw-class-list.json",
64
- removeUniversalSelector: true,
65
- loose: true
62
+ file: ".tw-patch/tw-class-list.json",
63
+ stripUniversalSelector: true,
64
+ pretty: true
66
65
  },
67
- tailwindcss: {}
66
+ tailwind: {}
68
67
  };
69
68
  }
70
- function getDefaultMangleUserConfig() {
69
+ function getDefaultTransformerConfig() {
71
70
  return {
72
- mangleClassFilter: import_shared.defaultMangleClassFilter,
73
- include: defaultPipelineInclude,
74
- exclude: defaultPipelineExclude,
71
+ filter: import_shared.defaultMangleClassFilter,
72
+ sources: {
73
+ include: defaultPipelineInclude,
74
+ exclude: defaultPipelineExclude
75
+ },
75
76
  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
77
+ registry: {
78
+ file: ".tw-patch/tw-class-list.json",
79
+ mapping: {
80
+ enabled: false,
81
+ file: ".tw-patch/tw-map-list.json",
82
+ loose: true
83
+ }
81
84
  },
82
- preserveFunction: []
85
+ preserve: {
86
+ functions: [],
87
+ classes: []
88
+ }
83
89
  };
84
90
  }
85
91
  function getDefaultUserConfig() {
86
92
  return {
87
- patch: getDefaultPatchConfig(),
88
- mangle: getDefaultMangleUserConfig()
93
+ registry: getDefaultRegistryConfig(),
94
+ transformer: getDefaultTransformerConfig()
89
95
  };
90
96
  }
91
97
 
92
98
  // src/config.ts
93
- function getConfig(cwd) {
94
- return (0, import_c12.loadConfig)({
99
+ var c12Promise;
100
+ async function loadC12() {
101
+ if (!c12Promise) {
102
+ c12Promise = import("c12");
103
+ }
104
+ return c12Promise;
105
+ }
106
+ async function getConfig(cwd) {
107
+ const { loadConfig } = await loadC12();
108
+ return loadConfig({
95
109
  name: CONFIG_NAME,
96
110
  defaults: {
97
111
  ...getDefaultUserConfig()
@@ -99,13 +113,24 @@ function getConfig(cwd) {
99
113
  cwd
100
114
  });
101
115
  }
102
- var defineConfig = (0, import_c12.createDefineConfig)();
116
+ var defineConfig = (config) => config;
103
117
  function initConfig(cwd) {
104
118
  return import_fs_extra.default.outputFile(
105
119
  import_pathe.default.resolve(cwd, `${CONFIG_NAME}.config.ts`),
106
120
  `import { defineConfig } from 'tailwindcss-patch'
107
121
 
108
- export default defineConfig({})
122
+ export default defineConfig({
123
+ registry: {
124
+ output: {
125
+ file: '.tw-patch/tw-class-list.json',
126
+ },
127
+ },
128
+ transformer: {
129
+ registry: {
130
+ file: '.tw-patch/tw-class-list.json',
131
+ },
132
+ },
133
+ })
109
134
  `,
110
135
  "utf8"
111
136
  );
@@ -115,8 +140,8 @@ export default defineConfig({})
115
140
  CONFIG_NAME,
116
141
  defineConfig,
117
142
  getConfig,
118
- getDefaultMangleUserConfig,
119
- getDefaultPatchConfig,
143
+ getDefaultRegistryConfig,
144
+ getDefaultTransformerConfig,
120
145
  getDefaultUserConfig,
121
146
  initConfig
122
147
  });
package/dist/index.d.cts CHANGED
@@ -1,76 +1,84 @@
1
- import * as c12 from 'c12';
1
+ import { ResolvedConfig, createDefineConfig } from 'c12';
2
2
  import { FilterPattern } from '@rollup/pluginutils';
3
3
  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
+ type DefineConfig = ReturnType<typeof createDefineConfig<TailwindcssMangleConfig>>;
74
+ declare function getConfig(cwd?: string): Promise<ResolvedConfig<TailwindcssMangleConfig>>;
75
+ declare const defineConfig: DefineConfig;
68
76
  declare function initConfig(cwd: string): Promise<void>;
69
77
 
70
78
  declare const CONFIG_NAME = "tailwindcss-mangle";
71
79
 
72
- declare function getDefaultPatchConfig(): PatchUserConfig;
73
- declare function getDefaultMangleUserConfig(): MangleUserConfig;
74
- declare function getDefaultUserConfig(): UserConfig;
80
+ declare function getDefaultRegistryConfig(): RegistryOptions;
81
+ declare function getDefaultTransformerConfig(): TransformerOptions;
82
+ declare function getDefaultUserConfig(): TailwindcssMangleConfig;
75
83
 
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 };
84
+ 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
@@ -1,76 +1,84 @@
1
- import * as c12 from 'c12';
1
+ import { ResolvedConfig, createDefineConfig } from 'c12';
2
2
  import { FilterPattern } from '@rollup/pluginutils';
3
3
  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
+ type DefineConfig = ReturnType<typeof createDefineConfig<TailwindcssMangleConfig>>;
74
+ declare function getConfig(cwd?: string): Promise<ResolvedConfig<TailwindcssMangleConfig>>;
75
+ declare const defineConfig: DefineConfig;
68
76
  declare function initConfig(cwd: string): Promise<void>;
69
77
 
70
78
  declare const CONFIG_NAME = "tailwindcss-mangle";
71
79
 
72
- declare function getDefaultPatchConfig(): PatchUserConfig;
73
- declare function getDefaultMangleUserConfig(): MangleUserConfig;
74
- declare function getDefaultUserConfig(): UserConfig;
80
+ declare function getDefaultRegistryConfig(): RegistryOptions;
81
+ declare function getDefaultTransformerConfig(): TransformerOptions;
82
+ declare function getDefaultUserConfig(): TailwindcssMangleConfig;
75
83
 
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 };
84
+ 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
@@ -1,5 +1,4 @@
1
1
  // src/config.ts
2
- import { createDefineConfig, loadConfig } from "c12";
3
2
  import fs from "fs-extra";
4
3
  import path from "pathe";
5
4
 
@@ -15,40 +14,55 @@ var defaultPipelineInclude = [
15
14
  CSS_LANGS_RE
16
15
  ];
17
16
  var defaultPipelineExclude = [];
18
- function getDefaultPatchConfig() {
17
+ function getDefaultRegistryConfig() {
19
18
  return {
20
19
  output: {
21
- filename: ".tw-patch/tw-class-list.json",
22
- removeUniversalSelector: true,
23
- loose: true
20
+ file: ".tw-patch/tw-class-list.json",
21
+ stripUniversalSelector: true,
22
+ pretty: true
24
23
  },
25
- tailwindcss: {}
24
+ tailwind: {}
26
25
  };
27
26
  }
28
- function getDefaultMangleUserConfig() {
27
+ function getDefaultTransformerConfig() {
29
28
  return {
30
- mangleClassFilter: defaultMangleClassFilter,
31
- include: defaultPipelineInclude,
32
- exclude: defaultPipelineExclude,
29
+ filter: defaultMangleClassFilter,
30
+ sources: {
31
+ include: defaultPipelineInclude,
32
+ exclude: defaultPipelineExclude
33
+ },
33
34
  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
35
+ registry: {
36
+ file: ".tw-patch/tw-class-list.json",
37
+ mapping: {
38
+ enabled: false,
39
+ file: ".tw-patch/tw-map-list.json",
40
+ loose: true
41
+ }
39
42
  },
40
- preserveFunction: []
43
+ preserve: {
44
+ functions: [],
45
+ classes: []
46
+ }
41
47
  };
42
48
  }
43
49
  function getDefaultUserConfig() {
44
50
  return {
45
- patch: getDefaultPatchConfig(),
46
- mangle: getDefaultMangleUserConfig()
51
+ registry: getDefaultRegistryConfig(),
52
+ transformer: getDefaultTransformerConfig()
47
53
  };
48
54
  }
49
55
 
50
56
  // src/config.ts
51
- function getConfig(cwd) {
57
+ var c12Promise;
58
+ async function loadC12() {
59
+ if (!c12Promise) {
60
+ c12Promise = import("c12");
61
+ }
62
+ return c12Promise;
63
+ }
64
+ async function getConfig(cwd) {
65
+ const { loadConfig } = await loadC12();
52
66
  return loadConfig({
53
67
  name: CONFIG_NAME,
54
68
  defaults: {
@@ -57,13 +71,24 @@ function getConfig(cwd) {
57
71
  cwd
58
72
  });
59
73
  }
60
- var defineConfig = createDefineConfig();
74
+ var defineConfig = (config) => config;
61
75
  function initConfig(cwd) {
62
76
  return fs.outputFile(
63
77
  path.resolve(cwd, `${CONFIG_NAME}.config.ts`),
64
78
  `import { defineConfig } from 'tailwindcss-patch'
65
79
 
66
- export default defineConfig({})
80
+ export default defineConfig({
81
+ registry: {
82
+ output: {
83
+ file: '.tw-patch/tw-class-list.json',
84
+ },
85
+ },
86
+ transformer: {
87
+ registry: {
88
+ file: '.tw-patch/tw-class-list.json',
89
+ },
90
+ },
91
+ })
67
92
  `,
68
93
  "utf8"
69
94
  );
@@ -72,8 +97,8 @@ export {
72
97
  CONFIG_NAME,
73
98
  defineConfig,
74
99
  getConfig,
75
- getDefaultMangleUserConfig,
76
- getDefaultPatchConfig,
100
+ getDefaultRegistryConfig,
101
+ getDefaultTransformerConfig,
77
102
  getDefaultUserConfig,
78
103
  initConfig
79
104
  };
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.1",
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",