unplugin-tailwindcss-mangle 2.3.0 → 3.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/esbuild.cjs CHANGED
@@ -1,13 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
- require('unplugin');
7
4
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
- require('@tailwindcss-mangle/shared');
5
+ require('is-css-request');
6
+ require('@rollup/pluginutils');
7
+ require('unplugin');
8
+ require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
11
9
 
12
10
  const esbuild = index.esbuild;
13
11
 
package/dist/esbuild.mjs CHANGED
@@ -1,11 +1,9 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
- import 'unplugin';
5
2
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
- import '@tailwindcss-mangle/shared';
3
+ import 'is-css-request';
4
+ import '@rollup/pluginutils';
5
+ import 'unplugin';
6
+ import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
9
7
 
10
8
  const esbuild = unplugin.esbuild;
11
9
 
package/dist/index.cjs CHANGED
@@ -1,139 +1,66 @@
1
1
  'use strict';
2
2
 
3
- const path = require('node:path');
4
- const fs = require('node:fs/promises');
5
3
  const unplugin$1 = require('unplugin');
6
4
  const core = require('@tailwindcss-mangle/core');
7
- const MagicString = require('magic-string');
8
- const utils = require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
9
- require('@tailwindcss-mangle/shared');
5
+ const isCssRequest = require('is-css-request');
6
+ const pluginutils = require('@rollup/pluginutils');
7
+ const constants = require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
10
8
 
11
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
12
-
13
- const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
14
- const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
15
-
16
- const unplugin = unplugin$1.createUnplugin((options) => {
9
+ const factory = (options) => {
17
10
  const ctx = new core.Context();
18
- return {
19
- name: utils.pluginName,
20
- enforce: "pre",
21
- async buildStart() {
22
- await ctx.initConfig({
23
- mangleOptions: options
24
- });
25
- },
26
- transformInclude(id) {
27
- return ctx.isInclude(id);
28
- },
29
- transform(code, id) {
30
- const s = new MagicString__default(code);
31
- if (/\.[jt]sx?$/.test(id)) {
32
- return core.preProcessJs({
33
- code: s,
34
- ctx,
35
- id
36
- });
37
- } else if (/\.vue/.test(id)) {
38
- return core.vueHandler(code, {
39
- ctx
40
- });
41
- } else {
42
- return core.preProcessRawCode({
43
- code,
44
- ctx,
45
- id
11
+ let filter = (_id) => true;
12
+ return [
13
+ {
14
+ name: `${constants.pluginName}:pre`,
15
+ // enforce: 'pre',
16
+ async buildStart() {
17
+ await ctx.initConfig({
18
+ mangleOptions: options
46
19
  });
20
+ filter = pluginutils.createFilter(ctx.options.include, ctx.options.exclude);
47
21
  }
48
22
  },
49
- vite: {
50
- generateBundle: {
51
- async handler(options2, bundle) {
52
- const groupedEntries = utils.getGroupedEntries(Object.entries(bundle));
53
- if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
54
- for (let i = 0; i < groupedEntries.css.length; i++) {
55
- const [file, cssSource] = groupedEntries.css[i];
56
- const { css } = await core.cssHandler(cssSource.source.toString(), {
57
- file,
58
- ctx
59
- });
60
- cssSource.source = css;
61
- }
23
+ {
24
+ name: `${constants.pluginName}`,
25
+ transformInclude(id) {
26
+ return filter(id);
27
+ },
28
+ async transform(code, id) {
29
+ const opts = {
30
+ ctx,
31
+ id
32
+ };
33
+ if (/\.[jt]sx?(?:$|\?)/.test(id)) {
34
+ return core.jsHandler(code, opts);
35
+ } else if (/\.(?:vue|svelte)(?:$|\?)/.test(id)) {
36
+ if (isCssRequest.isCSSRequest(id)) {
37
+ return await core.cssHandler(code, opts);
38
+ } else {
39
+ return core.jsHandler(code, opts);
62
40
  }
41
+ } else if (isCssRequest.isCSSRequest(id)) {
42
+ return await core.cssHandler(code, opts);
43
+ } else if (/\.html?/.test(id)) {
44
+ return core.htmlHandler(code, opts);
63
45
  }
64
46
  }
65
47
  },
66
- webpack(compiler) {
67
- const { Compilation, sources } = compiler.webpack;
68
- const { ConcatSource } = sources;
69
- compiler.hooks.compilation.tap(utils.pluginName, (compilation) => {
70
- compilation.hooks.processAssets.tapPromise(
71
- {
72
- name: utils.pluginName,
73
- stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
74
- },
75
- async (assets) => {
76
- const groupedEntries = utils.getGroupedEntries(Object.entries(assets));
77
- if (groupedEntries.js.length > 0) {
78
- for (let i = 0; i < groupedEntries.js.length; i++) {
79
- const [file, chunk] = groupedEntries.js[i];
80
- const code = core.jsHandler(chunk.source().toString(), {
81
- ctx
82
- }).code;
83
- if (code) {
84
- const source = new ConcatSource(code);
85
- compilation.updateAsset(file, source);
86
- }
87
- }
88
- }
89
- if (groupedEntries.css.length > 0) {
90
- for (let i = 0; i < groupedEntries.css.length; i++) {
91
- const [file, cssSource] = groupedEntries.css[i];
92
- const { css } = await core.cssHandler(cssSource.source().toString(), {
93
- file,
94
- ctx
95
- });
96
- const source = new ConcatSource(css);
97
- compilation.updateAsset(file, source);
98
- }
99
- }
100
- if (groupedEntries.html.length > 0) {
101
- for (let i = 0; i < groupedEntries.html.length; i++) {
102
- const [file, asset] = groupedEntries.html[i];
103
- const html = core.htmlHandler(asset.source().toString(), {
104
- ctx
105
- });
106
- const source = new ConcatSource(html);
107
- compilation.updateAsset(file, source);
108
- }
109
- }
110
- }
111
- );
112
- });
113
- },
114
- async writeBundle() {
115
- if (ctx.options.classMapOutput?.enable) {
116
- const opts = ctx.options.classMapOutput;
117
- const entries = Object.entries(ctx.classGenerator.newClassMap);
118
- if (entries.length > 0 && opts) {
119
- await utils.ensureDir(path.dirname(opts.filename));
120
- const output = JSON.stringify(
121
- entries.map((x) => {
122
- return {
123
- origin: x[0],
124
- replacement: x[1].name,
125
- usedBy: [...x[1].usedBy]
126
- };
127
- }),
128
- null,
129
- opts.loose ? 2 : 0
130
- );
131
- await fs__default.writeFile(opts.filename, output, "utf8");
132
- console.log(`\u2728 ${opts.filename} generated!`);
48
+ {
49
+ name: `${constants.pluginName}:post`,
50
+ enforce: "post",
51
+ vite: {
52
+ transformIndexHtml(html) {
53
+ const { code } = core.htmlHandler(html, { ctx });
54
+ return code;
133
55
  }
56
+ },
57
+ writeBundle() {
58
+ ctx.dump();
134
59
  }
135
60
  }
136
- };
137
- });
61
+ ];
62
+ };
63
+
64
+ const unplugin = unplugin$1.createUnplugin(factory);
138
65
 
139
66
  module.exports = unplugin;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unplugin from 'unplugin';
2
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config_index.MangleUserConfig | undefined, boolean>;
5
5
 
6
6
  export { unplugin as default };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unplugin from 'unplugin';
2
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config_index.MangleUserConfig | undefined, boolean>;
5
5
 
6
6
  export { unplugin as default };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unplugin from 'unplugin';
2
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config_index.MangleUserConfig | undefined, boolean>;
5
5
 
6
6
  export { unplugin as default };
package/dist/index.mjs CHANGED
@@ -1,132 +1,64 @@
1
- import { dirname } from 'node:path';
2
- import fs from 'node:fs/promises';
3
1
  import { createUnplugin } from 'unplugin';
4
- import { Context, preProcessJs, vueHandler, preProcessRawCode, cssHandler, jsHandler, htmlHandler } from '@tailwindcss-mangle/core';
5
- import MagicString from 'magic-string';
6
- import { p as pluginName, g as getGroupedEntries, e as ensureDir } from './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
7
- import '@tailwindcss-mangle/shared';
2
+ import { Context, jsHandler, cssHandler, htmlHandler } from '@tailwindcss-mangle/core';
3
+ import { isCSSRequest } from 'is-css-request';
4
+ import { createFilter } from '@rollup/pluginutils';
5
+ import { p as pluginName } from './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
8
6
 
9
- const unplugin = createUnplugin((options) => {
7
+ const factory = (options) => {
10
8
  const ctx = new Context();
11
- return {
12
- name: pluginName,
13
- enforce: "pre",
14
- async buildStart() {
15
- await ctx.initConfig({
16
- mangleOptions: options
17
- });
18
- },
19
- transformInclude(id) {
20
- return ctx.isInclude(id);
21
- },
22
- transform(code, id) {
23
- const s = new MagicString(code);
24
- if (/\.[jt]sx?$/.test(id)) {
25
- return preProcessJs({
26
- code: s,
27
- ctx,
28
- id
29
- });
30
- } else if (/\.vue/.test(id)) {
31
- return vueHandler(code, {
32
- ctx
33
- });
34
- } else {
35
- return preProcessRawCode({
36
- code,
37
- ctx,
38
- id
9
+ let filter = (_id) => true;
10
+ return [
11
+ {
12
+ name: `${pluginName}:pre`,
13
+ // enforce: 'pre',
14
+ async buildStart() {
15
+ await ctx.initConfig({
16
+ mangleOptions: options
39
17
  });
18
+ filter = createFilter(ctx.options.include, ctx.options.exclude);
40
19
  }
41
20
  },
42
- vite: {
43
- generateBundle: {
44
- async handler(options2, bundle) {
45
- const groupedEntries = getGroupedEntries(Object.entries(bundle));
46
- if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
47
- for (let i = 0; i < groupedEntries.css.length; i++) {
48
- const [file, cssSource] = groupedEntries.css[i];
49
- const { css } = await cssHandler(cssSource.source.toString(), {
50
- file,
51
- ctx
52
- });
53
- cssSource.source = css;
54
- }
21
+ {
22
+ name: `${pluginName}`,
23
+ transformInclude(id) {
24
+ return filter(id);
25
+ },
26
+ async transform(code, id) {
27
+ const opts = {
28
+ ctx,
29
+ id
30
+ };
31
+ if (/\.[jt]sx?(?:$|\?)/.test(id)) {
32
+ return jsHandler(code, opts);
33
+ } else if (/\.(?:vue|svelte)(?:$|\?)/.test(id)) {
34
+ if (isCSSRequest(id)) {
35
+ return await cssHandler(code, opts);
36
+ } else {
37
+ return jsHandler(code, opts);
55
38
  }
39
+ } else if (isCSSRequest(id)) {
40
+ return await cssHandler(code, opts);
41
+ } else if (/\.html?/.test(id)) {
42
+ return htmlHandler(code, opts);
56
43
  }
57
44
  }
58
45
  },
59
- webpack(compiler) {
60
- const { Compilation, sources } = compiler.webpack;
61
- const { ConcatSource } = sources;
62
- compiler.hooks.compilation.tap(pluginName, (compilation) => {
63
- compilation.hooks.processAssets.tapPromise(
64
- {
65
- name: pluginName,
66
- stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
67
- },
68
- async (assets) => {
69
- const groupedEntries = getGroupedEntries(Object.entries(assets));
70
- if (groupedEntries.js.length > 0) {
71
- for (let i = 0; i < groupedEntries.js.length; i++) {
72
- const [file, chunk] = groupedEntries.js[i];
73
- const code = jsHandler(chunk.source().toString(), {
74
- ctx
75
- }).code;
76
- if (code) {
77
- const source = new ConcatSource(code);
78
- compilation.updateAsset(file, source);
79
- }
80
- }
81
- }
82
- if (groupedEntries.css.length > 0) {
83
- for (let i = 0; i < groupedEntries.css.length; i++) {
84
- const [file, cssSource] = groupedEntries.css[i];
85
- const { css } = await cssHandler(cssSource.source().toString(), {
86
- file,
87
- ctx
88
- });
89
- const source = new ConcatSource(css);
90
- compilation.updateAsset(file, source);
91
- }
92
- }
93
- if (groupedEntries.html.length > 0) {
94
- for (let i = 0; i < groupedEntries.html.length; i++) {
95
- const [file, asset] = groupedEntries.html[i];
96
- const html = htmlHandler(asset.source().toString(), {
97
- ctx
98
- });
99
- const source = new ConcatSource(html);
100
- compilation.updateAsset(file, source);
101
- }
102
- }
103
- }
104
- );
105
- });
106
- },
107
- async writeBundle() {
108
- if (ctx.options.classMapOutput?.enable) {
109
- const opts = ctx.options.classMapOutput;
110
- const entries = Object.entries(ctx.classGenerator.newClassMap);
111
- if (entries.length > 0 && opts) {
112
- await ensureDir(dirname(opts.filename));
113
- const output = JSON.stringify(
114
- entries.map((x) => {
115
- return {
116
- origin: x[0],
117
- replacement: x[1].name,
118
- usedBy: [...x[1].usedBy]
119
- };
120
- }),
121
- null,
122
- opts.loose ? 2 : 0
123
- );
124
- await fs.writeFile(opts.filename, output, "utf8");
125
- console.log(`\u2728 ${opts.filename} generated!`);
46
+ {
47
+ name: `${pluginName}:post`,
48
+ enforce: "post",
49
+ vite: {
50
+ transformIndexHtml(html) {
51
+ const { code } = htmlHandler(html, { ctx });
52
+ return code;
126
53
  }
54
+ },
55
+ writeBundle() {
56
+ ctx.dump();
127
57
  }
128
58
  }
129
- };
130
- });
59
+ ];
60
+ };
61
+
62
+ const unplugin = createUnplugin(factory);
131
63
 
132
64
  export { unplugin as default };
package/dist/nuxt.cjs CHANGED
@@ -1,13 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
- require('unplugin');
7
4
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
- require('@tailwindcss-mangle/shared');
5
+ require('is-css-request');
6
+ require('@rollup/pluginutils');
7
+ require('unplugin');
8
+ require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
11
9
 
12
10
  function nuxt(options = {}, nuxt) {
13
11
  nuxt.hook("webpack:config", (config) => {
package/dist/nuxt.mjs CHANGED
@@ -1,11 +1,9 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
- import 'unplugin';
5
2
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
- import '@tailwindcss-mangle/shared';
3
+ import 'is-css-request';
4
+ import '@rollup/pluginutils';
5
+ import 'unplugin';
6
+ import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
9
7
 
10
8
  function nuxt(options = {}, nuxt) {
11
9
  nuxt.hook("webpack:config", (config) => {
package/dist/rollup.cjs CHANGED
@@ -1,13 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
- require('unplugin');
7
4
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
- require('@tailwindcss-mangle/shared');
5
+ require('is-css-request');
6
+ require('@rollup/pluginutils');
7
+ require('unplugin');
8
+ require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
11
9
 
12
10
  const rollup = index.rollup;
13
11
 
package/dist/rollup.mjs CHANGED
@@ -1,11 +1,9 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
- import 'unplugin';
5
2
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
- import '@tailwindcss-mangle/shared';
3
+ import 'is-css-request';
4
+ import '@rollup/pluginutils';
5
+ import 'unplugin';
6
+ import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
9
7
 
10
8
  const rollup = unplugin.rollup;
11
9
 
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const pluginName = "unplugin-tailwindcss-mangle";
4
+
5
+ exports.pluginName = pluginName;
@@ -0,0 +1,3 @@
1
+ const pluginName = "unplugin-tailwindcss-mangle";
2
+
3
+ export { pluginName as p };
package/dist/utils.cjs CHANGED
@@ -1,16 +1,77 @@
1
1
  'use strict';
2
2
 
3
- require('node:fs/promises');
4
- require('node:path');
3
+ const fs = require('node:fs/promises');
4
+ const path = require('node:path');
5
+ const process = require('node:process');
5
6
  const shared = require('@tailwindcss-mangle/shared');
6
- const utils = require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
7
+ const constants = require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
7
8
 
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
8
10
 
11
+ const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
12
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
13
+ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
14
+
15
+ function escapeStringRegexp(str) {
16
+ if (typeof str !== "string") {
17
+ throw new TypeError("Expected a string");
18
+ }
19
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
20
+ }
21
+ function getGroupedEntries(entries, options = {
22
+ cssMatcher(file) {
23
+ return /\.css$/.test(file);
24
+ },
25
+ htmlMatcher(file) {
26
+ return /\.html?$/.test(file);
27
+ },
28
+ jsMatcher(file) {
29
+ return /\.[cm]?js$/.test(file);
30
+ }
31
+ }) {
32
+ const { cssMatcher, htmlMatcher, jsMatcher } = options;
33
+ const groupedEntries = shared.groupBy(entries, ([file]) => {
34
+ if (cssMatcher(file)) {
35
+ return "css";
36
+ } else if (htmlMatcher(file)) {
37
+ return "html";
38
+ } else if (jsMatcher(file)) {
39
+ return "js";
40
+ } else {
41
+ return "other";
42
+ }
43
+ });
44
+ if (!groupedEntries.css) {
45
+ groupedEntries.css = [];
46
+ }
47
+ if (!groupedEntries.html) {
48
+ groupedEntries.html = [];
49
+ }
50
+ if (!groupedEntries.js) {
51
+ groupedEntries.js = [];
52
+ }
53
+ if (!groupedEntries.other) {
54
+ groupedEntries.other = [];
55
+ }
56
+ return groupedEntries;
57
+ }
58
+ function getCacheDir(basedir = process__default.cwd()) {
59
+ return path__default.resolve(basedir, "node_modules/.cache", constants.pluginName);
60
+ }
61
+ async function ensureDir(p) {
62
+ try {
63
+ await fs__default.access(p);
64
+ } catch {
65
+ await fs__default.mkdir(p, {
66
+ recursive: true
67
+ });
68
+ }
69
+ }
9
70
 
10
71
  exports.defaultMangleClassFilter = shared.defaultMangleClassFilter;
11
72
  exports.isMap = shared.isMap;
12
73
  exports.isRegexp = shared.isRegexp;
13
- exports.ensureDir = utils.ensureDir;
14
- exports.escapeStringRegexp = utils.escapeStringRegexp;
15
- exports.getCacheDir = utils.getCacheDir;
16
- exports.getGroupedEntries = utils.getGroupedEntries;
74
+ exports.ensureDir = ensureDir;
75
+ exports.escapeStringRegexp = escapeStringRegexp;
76
+ exports.getCacheDir = getCacheDir;
77
+ exports.getGroupedEntries = getGroupedEntries;
package/dist/utils.mjs CHANGED
@@ -1,4 +1,64 @@
1
- import 'node:fs/promises';
2
- import 'node:path';
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import process from 'node:process';
4
+ import { groupBy } from '@tailwindcss-mangle/shared';
3
5
  export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
4
- export { e as ensureDir, a as escapeStringRegexp, b as getCacheDir, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
6
+ import { p as pluginName } from './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
7
+
8
+ function escapeStringRegexp(str) {
9
+ if (typeof str !== "string") {
10
+ throw new TypeError("Expected a string");
11
+ }
12
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
13
+ }
14
+ function getGroupedEntries(entries, options = {
15
+ cssMatcher(file) {
16
+ return /\.css$/.test(file);
17
+ },
18
+ htmlMatcher(file) {
19
+ return /\.html?$/.test(file);
20
+ },
21
+ jsMatcher(file) {
22
+ return /\.[cm]?js$/.test(file);
23
+ }
24
+ }) {
25
+ const { cssMatcher, htmlMatcher, jsMatcher } = options;
26
+ const groupedEntries = groupBy(entries, ([file]) => {
27
+ if (cssMatcher(file)) {
28
+ return "css";
29
+ } else if (htmlMatcher(file)) {
30
+ return "html";
31
+ } else if (jsMatcher(file)) {
32
+ return "js";
33
+ } else {
34
+ return "other";
35
+ }
36
+ });
37
+ if (!groupedEntries.css) {
38
+ groupedEntries.css = [];
39
+ }
40
+ if (!groupedEntries.html) {
41
+ groupedEntries.html = [];
42
+ }
43
+ if (!groupedEntries.js) {
44
+ groupedEntries.js = [];
45
+ }
46
+ if (!groupedEntries.other) {
47
+ groupedEntries.other = [];
48
+ }
49
+ return groupedEntries;
50
+ }
51
+ function getCacheDir(basedir = process.cwd()) {
52
+ return path.resolve(basedir, "node_modules/.cache", pluginName);
53
+ }
54
+ async function ensureDir(p) {
55
+ try {
56
+ await fs.access(p);
57
+ } catch {
58
+ await fs.mkdir(p, {
59
+ recursive: true
60
+ });
61
+ }
62
+ }
63
+
64
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
package/dist/vite.cjs CHANGED
@@ -1,13 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
- require('unplugin');
7
4
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
- require('@tailwindcss-mangle/shared');
5
+ require('is-css-request');
6
+ require('@rollup/pluginutils');
7
+ require('unplugin');
8
+ require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
11
9
 
12
10
  const vite = index.vite;
13
11
 
package/dist/vite.mjs CHANGED
@@ -1,11 +1,9 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
- import 'unplugin';
5
2
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
- import '@tailwindcss-mangle/shared';
3
+ import 'is-css-request';
4
+ import '@rollup/pluginutils';
5
+ import 'unplugin';
6
+ import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
9
7
 
10
8
  const vite = unplugin.vite;
11
9
 
package/dist/webpack.cjs CHANGED
@@ -1,13 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
- require('unplugin');
7
4
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
- require('@tailwindcss-mangle/shared');
5
+ require('is-css-request');
6
+ require('@rollup/pluginutils');
7
+ require('unplugin');
8
+ require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
11
9
 
12
10
  const webpack = index.webpack;
13
11
 
package/dist/webpack.mjs CHANGED
@@ -1,11 +1,9 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
- import 'unplugin';
5
2
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
- import '@tailwindcss-mangle/shared';
3
+ import 'is-css-request';
4
+ import '@rollup/pluginutils';
5
+ import 'unplugin';
6
+ import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
9
7
 
10
8
  const webpack = unplugin.webpack;
11
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
5
5
  "author": "SonOfMagic <qq1324318532@gmail.com>",
6
6
  "license": "MIT",
@@ -70,11 +70,13 @@
70
70
  "dist"
71
71
  ],
72
72
  "dependencies": {
73
+ "@rollup/pluginutils": "^5.1.0",
74
+ "is-css-request": "^1.0.0",
73
75
  "magic-string": "^0.30.10",
74
76
  "unplugin": "^1.10.1",
75
- "@tailwindcss-mangle/config": "^2.2.2",
76
- "@tailwindcss-mangle/core": "^2.3.0",
77
- "@tailwindcss-mangle/shared": "^2.2.2"
77
+ "@tailwindcss-mangle/config": "^3.0.0",
78
+ "@tailwindcss-mangle/core": "^3.0.0",
79
+ "@tailwindcss-mangle/shared": "^3.0.0"
78
80
  },
79
81
  "publishConfig": {
80
82
  "access": "public",
@@ -82,7 +84,7 @@
82
84
  },
83
85
  "devDependencies": {
84
86
  "@types/babel__helper-plugin-utils": "^7.10.3",
85
- "astro": "^4.10.3",
87
+ "astro": "^4.11.0",
86
88
  "css-loader": "^7.1.2",
87
89
  "html-webpack-plugin": "^5.6.0",
88
90
  "mini-css-extract-plugin": "^2.9.0",
@@ -91,7 +93,7 @@
91
93
  "postcss-loader": "^8.1.1",
92
94
  "tailwindcss": "^3.4.4",
93
95
  "vite": "^5.3.1",
94
- "webpack": "^5.92.0",
96
+ "webpack": "^5.92.1",
95
97
  "webpack-build-utils": "^0.0.7",
96
98
  "tailwindcss-patch": "^3.0.1"
97
99
  },
@@ -1,74 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('node:fs/promises');
4
- const path = require('node:path');
5
- const shared = require('@tailwindcss-mangle/shared');
6
-
7
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
8
-
9
- const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
10
- const path__default = /*#__PURE__*/_interopDefaultCompat(path);
11
-
12
- const pluginName = "unplugin-tailwindcss-mangle";
13
-
14
- function escapeStringRegexp(str) {
15
- if (typeof str !== "string") {
16
- throw new TypeError("Expected a string");
17
- }
18
- return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
19
- }
20
- function getGroupedEntries(entries, options = {
21
- cssMatcher(file) {
22
- return /\.css$/.test(file);
23
- },
24
- htmlMatcher(file) {
25
- return /\.html?$/.test(file);
26
- },
27
- jsMatcher(file) {
28
- return /\.[cm]?js$/.test(file);
29
- }
30
- }) {
31
- const { cssMatcher, htmlMatcher, jsMatcher } = options;
32
- const groupedEntries = shared.groupBy(entries, ([file]) => {
33
- if (cssMatcher(file)) {
34
- return "css";
35
- } else if (htmlMatcher(file)) {
36
- return "html";
37
- } else if (jsMatcher(file)) {
38
- return "js";
39
- } else {
40
- return "other";
41
- }
42
- });
43
- if (!groupedEntries.css) {
44
- groupedEntries.css = [];
45
- }
46
- if (!groupedEntries.html) {
47
- groupedEntries.html = [];
48
- }
49
- if (!groupedEntries.js) {
50
- groupedEntries.js = [];
51
- }
52
- if (!groupedEntries.other) {
53
- groupedEntries.other = [];
54
- }
55
- return groupedEntries;
56
- }
57
- function getCacheDir(basedir = process.cwd()) {
58
- return path__default.resolve(basedir, "node_modules/.cache", pluginName);
59
- }
60
- async function ensureDir(p) {
61
- try {
62
- await fs__default.access(p);
63
- } catch {
64
- await fs__default.mkdir(p, {
65
- recursive: true
66
- });
67
- }
68
- }
69
-
70
- exports.ensureDir = ensureDir;
71
- exports.escapeStringRegexp = escapeStringRegexp;
72
- exports.getCacheDir = getCacheDir;
73
- exports.getGroupedEntries = getGroupedEntries;
74
- exports.pluginName = pluginName;
@@ -1,63 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { groupBy } from '@tailwindcss-mangle/shared';
4
-
5
- const pluginName = "unplugin-tailwindcss-mangle";
6
-
7
- function escapeStringRegexp(str) {
8
- if (typeof str !== "string") {
9
- throw new TypeError("Expected a string");
10
- }
11
- return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
12
- }
13
- function getGroupedEntries(entries, options = {
14
- cssMatcher(file) {
15
- return /\.css$/.test(file);
16
- },
17
- htmlMatcher(file) {
18
- return /\.html?$/.test(file);
19
- },
20
- jsMatcher(file) {
21
- return /\.[cm]?js$/.test(file);
22
- }
23
- }) {
24
- const { cssMatcher, htmlMatcher, jsMatcher } = options;
25
- const groupedEntries = groupBy(entries, ([file]) => {
26
- if (cssMatcher(file)) {
27
- return "css";
28
- } else if (htmlMatcher(file)) {
29
- return "html";
30
- } else if (jsMatcher(file)) {
31
- return "js";
32
- } else {
33
- return "other";
34
- }
35
- });
36
- if (!groupedEntries.css) {
37
- groupedEntries.css = [];
38
- }
39
- if (!groupedEntries.html) {
40
- groupedEntries.html = [];
41
- }
42
- if (!groupedEntries.js) {
43
- groupedEntries.js = [];
44
- }
45
- if (!groupedEntries.other) {
46
- groupedEntries.other = [];
47
- }
48
- return groupedEntries;
49
- }
50
- function getCacheDir(basedir = process.cwd()) {
51
- return path.resolve(basedir, "node_modules/.cache", pluginName);
52
- }
53
- async function ensureDir(p) {
54
- try {
55
- await fs.access(p);
56
- } catch {
57
- await fs.mkdir(p, {
58
- recursive: true
59
- });
60
- }
61
- }
62
-
63
- export { escapeStringRegexp as a, getCacheDir as b, ensureDir as e, getGroupedEntries as g, pluginName as p };