unplugin-tailwindcss-mangle 2.3.0 → 3.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.
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ const core = require('@tailwindcss-mangle/core');
4
+
5
+ const TailwindcssMangleWebpackLoader = async function(source) {
6
+ const callback = this.async();
7
+ const { ctx } = this.getOptions();
8
+ const { code } = await core.cssHandler(source, {
9
+ ctx,
10
+ id: this.resource
11
+ });
12
+ callback(null, code);
13
+ };
14
+
15
+ module.exports = TailwindcssMangleWebpackLoader;
@@ -0,0 +1,8 @@
1
+ import { LoaderContext } from 'webpack';
2
+ import { Context } from '@tailwindcss-mangle/core';
3
+
4
+ declare const TailwindcssMangleWebpackLoader: (this: LoaderContext<{
5
+ ctx: Context;
6
+ }>, source: string) => Promise<void>;
7
+
8
+ export { TailwindcssMangleWebpackLoader as default };
@@ -0,0 +1,8 @@
1
+ import { LoaderContext } from 'webpack';
2
+ import { Context } from '@tailwindcss-mangle/core';
3
+
4
+ declare const TailwindcssMangleWebpackLoader: (this: LoaderContext<{
5
+ ctx: Context;
6
+ }>, source: string) => Promise<void>;
7
+
8
+ export { TailwindcssMangleWebpackLoader as default };
@@ -0,0 +1,8 @@
1
+ import { LoaderContext } from 'webpack';
2
+ import { Context } from '@tailwindcss-mangle/core';
3
+
4
+ declare const TailwindcssMangleWebpackLoader: (this: LoaderContext<{
5
+ ctx: Context;
6
+ }>, source: string) => Promise<void>;
7
+
8
+ export { TailwindcssMangleWebpackLoader as default };
@@ -0,0 +1,13 @@
1
+ import { cssHandler } from '@tailwindcss-mangle/core';
2
+
3
+ const TailwindcssMangleWebpackLoader = async function(source) {
4
+ const callback = this.async();
5
+ const { ctx } = this.getOptions();
6
+ const { code } = await cssHandler(source, {
7
+ ctx,
8
+ id: this.resource
9
+ });
10
+ callback(null, code);
11
+ };
12
+
13
+ export { TailwindcssMangleWebpackLoader as default };
package/dist/esbuild.cjs CHANGED
@@ -1,12 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
4
  require('unplugin');
5
+ require('node:path');
7
6
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
7
+ require('is-css-request');
8
+ require('@rollup/pluginutils');
9
+ require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
10
+ require('node:fs/promises');
11
+ require('node:process');
10
12
  require('@tailwindcss-mangle/shared');
11
13
 
12
14
  const esbuild = index.esbuild;
@@ -1,6 +1,6 @@
1
1
  import * as esbuild from 'esbuild';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => esbuild.Plugin;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => esbuild.Plugin;
5
5
 
6
6
  export { _default as default };
@@ -1,6 +1,6 @@
1
1
  import * as esbuild from 'esbuild';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => esbuild.Plugin;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => esbuild.Plugin;
5
5
 
6
6
  export { _default as default };
package/dist/esbuild.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as esbuild from 'esbuild';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => esbuild.Plugin;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => esbuild.Plugin;
5
5
 
6
6
  export { _default as default };
package/dist/esbuild.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
2
  import 'unplugin';
3
+ import 'node:path';
5
4
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
5
+ import 'is-css-request';
6
+ import '@rollup/pluginutils';
7
+ import './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
8
+ import 'node:fs/promises';
9
+ import 'node:process';
8
10
  import '@tailwindcss-mangle/shared';
9
11
 
10
12
  const esbuild = unplugin.esbuild;
package/dist/index.cjs CHANGED
@@ -1,139 +1,136 @@
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');
4
+ const path = require('node:path');
6
5
  const core = require('@tailwindcss-mangle/core');
7
- const MagicString = require('magic-string');
8
- const utils = require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
6
+ const isCssRequest = require('is-css-request');
7
+ const pluginutils = require('@rollup/pluginutils');
8
+ const utils = require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
9
+ require('node:fs/promises');
10
+ require('node:process');
9
11
  require('@tailwindcss-mangle/shared');
10
12
 
11
13
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
12
14
 
13
- const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
14
- const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
15
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
15
16
 
16
- const unplugin = unplugin$1.createUnplugin((options) => {
17
+ const WEBPACK_LOADER = path__default.resolve(__dirname, "core/loader.cjs");
18
+ const factory = (options, { framework }) => {
17
19
  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
20
+ let filter = (_id) => true;
21
+ return [
22
+ {
23
+ name: `${utils.pluginName}:pre`,
24
+ enforce: "pre",
25
+ async buildStart() {
26
+ await ctx.initConfig({
27
+ mangleOptions: options
46
28
  });
29
+ filter = pluginutils.createFilter(ctx.options.include, ctx.options.exclude);
47
30
  }
48
31
  },
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
- }
32
+ {
33
+ name: `${utils.pluginName}`,
34
+ transformInclude(id) {
35
+ return filter(id);
36
+ },
37
+ async transform(code, id) {
38
+ const opts = {
39
+ ctx,
40
+ id
41
+ };
42
+ if (/\.[jt]sx?(?:$|\?)/.test(id)) {
43
+ return core.jsHandler(code, opts);
44
+ } else if (/\.(?:vue|svelte)(?:$|\?)/.test(id)) {
45
+ if (isCssRequest.isCSSRequest(id)) {
46
+ return await core.cssHandler(code, opts);
47
+ } else {
48
+ return core.jsHandler(code, opts);
62
49
  }
50
+ } else if (isCssRequest.isCSSRequest(id)) {
51
+ return await core.cssHandler(code, opts);
52
+ } else if (/\.html?/.test(id)) {
53
+ return core.htmlHandler(code, opts);
63
54
  }
55
+ },
56
+ webpack(compiler) {
57
+ const { NormalModule } = compiler.webpack;
58
+ compiler.hooks.compilation.tap(utils.pluginName, (compilation) => {
59
+ NormalModule.getCompilationHooks(compilation).loader.tap(utils.pluginName, (_loaderContext, module) => {
60
+ {
61
+ const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
62
+ if (idx > -1) {
63
+ module.loaders.splice(idx, 0, {
64
+ loader: WEBPACK_LOADER,
65
+ ident: null,
66
+ options: {
67
+ ctx
68
+ },
69
+ type: null
70
+ });
71
+ }
72
+ }
73
+ });
74
+ });
64
75
  }
65
76
  },
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) {
77
+ {
78
+ name: `${utils.pluginName}:post`,
79
+ enforce: "post",
80
+ vite: {
81
+ transformIndexHtml(html) {
82
+ const { code } = core.htmlHandler(html, { ctx });
83
+ return code;
84
+ }
85
+ // generateBundle: {
86
+ // async handler(options, bundle) {
87
+ // const groupedEntries = getGroupedEntries(Object.entries(bundle))
88
+ // if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
89
+ // for (let i = 0; i < groupedEntries.css.length; i++) {
90
+ // const [id, cssSource] = groupedEntries.css[i] as [string, OutputAsset]
91
+ // const { code } = await cssHandler(cssSource.source.toString(), {
92
+ // id,
93
+ // ctx,
94
+ // })
95
+ // cssSource.source = code
96
+ // }
97
+ // }
98
+ // },
99
+ // },
100
+ },
101
+ webpack(compiler) {
102
+ const { Compilation, sources } = compiler.webpack;
103
+ const { ConcatSource } = sources;
104
+ compiler.hooks.compilation.tap(utils.pluginName, (compilation) => {
105
+ compilation.hooks.processAssets.tapPromise(
106
+ {
107
+ name: utils.pluginName,
108
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
109
+ },
110
+ async (assets) => {
111
+ const groupedEntries = utils.getGroupedEntries(Object.entries(assets));
112
+ if (groupedEntries.css.length > 0) {
113
+ for (let i = 0; i < groupedEntries.css.length; i++) {
114
+ const [id, cssSource] = groupedEntries.css[i];
115
+ const { code } = await core.cssHandler(cssSource.source().toString(), {
116
+ id,
117
+ ctx
118
+ });
84
119
  const source = new ConcatSource(code);
85
- compilation.updateAsset(file, source);
120
+ compilation.updateAsset(id, source);
86
121
  }
87
122
  }
88
123
  }
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
124
  );
131
- await fs__default.writeFile(opts.filename, output, "utf8");
132
- console.log(`\u2728 ${opts.filename} generated!`);
133
- }
125
+ });
126
+ },
127
+ writeBundle() {
128
+ ctx.dump();
134
129
  }
135
130
  }
136
- };
137
- });
131
+ ];
132
+ };
133
+
134
+ const unplugin = unplugin$1.createUnplugin(factory);
138
135
 
139
136
  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 from '@tailwindcss-mangle/config';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config.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 from '@tailwindcss-mangle/config';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config.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 from '@tailwindcss-mangle/config';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config.MangleUserConfig | undefined, boolean>;
5
5
 
6
6
  export { unplugin as default };
package/dist/index.mjs CHANGED
@@ -1,132 +1,139 @@
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';
2
+ import path from 'node:path';
3
+ import { Context, jsHandler, cssHandler, htmlHandler } from '@tailwindcss-mangle/core';
4
+ import { isCSSRequest } from 'is-css-request';
5
+ import { createFilter } from '@rollup/pluginutils';
6
+ import { p as pluginName, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
7
+ import 'node:fs/promises';
8
+ import 'node:process';
7
9
  import '@tailwindcss-mangle/shared';
8
10
 
9
- const unplugin = createUnplugin((options) => {
11
+
12
+
13
+ // -- Unbuild CommonJS Shims --
14
+ import __cjs_url__ from 'url';
15
+ import __cjs_path__ from 'path';
16
+ import __cjs_mod__ from 'module';
17
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
18
+ const __dirname = __cjs_path__.dirname(__filename);
19
+ const require = __cjs_mod__.createRequire(import.meta.url);
20
+ const WEBPACK_LOADER = path.resolve(__dirname, "core/loader.cjs");
21
+ const factory = (options, { framework }) => {
10
22
  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
23
+ let filter = (_id) => true;
24
+ return [
25
+ {
26
+ name: `${pluginName}:pre`,
27
+ enforce: "pre",
28
+ async buildStart() {
29
+ await ctx.initConfig({
30
+ mangleOptions: options
39
31
  });
32
+ filter = createFilter(ctx.options.include, ctx.options.exclude);
40
33
  }
41
34
  },
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
- }
35
+ {
36
+ name: `${pluginName}`,
37
+ transformInclude(id) {
38
+ return filter(id);
39
+ },
40
+ async transform(code, id) {
41
+ const opts = {
42
+ ctx,
43
+ id
44
+ };
45
+ if (/\.[jt]sx?(?:$|\?)/.test(id)) {
46
+ return jsHandler(code, opts);
47
+ } else if (/\.(?:vue|svelte)(?:$|\?)/.test(id)) {
48
+ if (isCSSRequest(id)) {
49
+ return await cssHandler(code, opts);
50
+ } else {
51
+ return jsHandler(code, opts);
55
52
  }
53
+ } else if (isCSSRequest(id)) {
54
+ return await cssHandler(code, opts);
55
+ } else if (/\.html?/.test(id)) {
56
+ return htmlHandler(code, opts);
56
57
  }
58
+ },
59
+ webpack(compiler) {
60
+ const { NormalModule } = compiler.webpack;
61
+ compiler.hooks.compilation.tap(pluginName, (compilation) => {
62
+ NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (_loaderContext, module) => {
63
+ {
64
+ const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
65
+ if (idx > -1) {
66
+ module.loaders.splice(idx, 0, {
67
+ loader: WEBPACK_LOADER,
68
+ ident: null,
69
+ options: {
70
+ ctx
71
+ },
72
+ type: null
73
+ });
74
+ }
75
+ }
76
+ });
77
+ });
57
78
  }
58
79
  },
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) {
80
+ {
81
+ name: `${pluginName}:post`,
82
+ enforce: "post",
83
+ vite: {
84
+ transformIndexHtml(html) {
85
+ const { code } = htmlHandler(html, { ctx });
86
+ return code;
87
+ }
88
+ // generateBundle: {
89
+ // async handler(options, bundle) {
90
+ // const groupedEntries = getGroupedEntries(Object.entries(bundle))
91
+ // if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
92
+ // for (let i = 0; i < groupedEntries.css.length; i++) {
93
+ // const [id, cssSource] = groupedEntries.css[i] as [string, OutputAsset]
94
+ // const { code } = await cssHandler(cssSource.source.toString(), {
95
+ // id,
96
+ // ctx,
97
+ // })
98
+ // cssSource.source = code
99
+ // }
100
+ // }
101
+ // },
102
+ // },
103
+ },
104
+ webpack(compiler) {
105
+ const { Compilation, sources } = compiler.webpack;
106
+ const { ConcatSource } = sources;
107
+ compiler.hooks.compilation.tap(pluginName, (compilation) => {
108
+ compilation.hooks.processAssets.tapPromise(
109
+ {
110
+ name: pluginName,
111
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
112
+ },
113
+ async (assets) => {
114
+ const groupedEntries = getGroupedEntries(Object.entries(assets));
115
+ if (groupedEntries.css.length > 0) {
116
+ for (let i = 0; i < groupedEntries.css.length; i++) {
117
+ const [id, cssSource] = groupedEntries.css[i];
118
+ const { code } = await cssHandler(cssSource.source().toString(), {
119
+ id,
120
+ ctx
121
+ });
77
122
  const source = new ConcatSource(code);
78
- compilation.updateAsset(file, source);
123
+ compilation.updateAsset(id, source);
79
124
  }
80
125
  }
81
126
  }
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
127
  );
124
- await fs.writeFile(opts.filename, output, "utf8");
125
- console.log(`\u2728 ${opts.filename} generated!`);
126
- }
128
+ });
129
+ },
130
+ writeBundle() {
131
+ ctx.dump();
127
132
  }
128
133
  }
129
- };
130
- });
134
+ ];
135
+ };
136
+
137
+ const unplugin = createUnplugin(factory);
131
138
 
132
139
  export { unplugin as default };
package/dist/rollup.cjs CHANGED
@@ -1,12 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
4
  require('unplugin');
5
+ require('node:path');
7
6
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
7
+ require('is-css-request');
8
+ require('@rollup/pluginutils');
9
+ require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
10
+ require('node:fs/promises');
11
+ require('node:process');
10
12
  require('@tailwindcss-mangle/shared');
11
13
 
12
14
  const rollup = index.rollup;
package/dist/rollup.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/rollup.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/rollup.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
2
  import 'unplugin';
3
+ import 'node:path';
5
4
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
5
+ import 'is-css-request';
6
+ import '@rollup/pluginutils';
7
+ import './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
8
+ import 'node:fs/promises';
9
+ import 'node:process';
8
10
  import '@tailwindcss-mangle/shared';
9
11
 
10
12
  const rollup = unplugin.rollup;
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
+ import process from 'node:process';
3
4
  import { groupBy } from '@tailwindcss-mangle/shared';
4
5
 
5
6
  const pluginName = "unplugin-tailwindcss-mangle";
@@ -60,4 +61,4 @@ async function ensureDir(p) {
60
61
  }
61
62
  }
62
63
 
63
- export { escapeStringRegexp as a, getCacheDir as b, ensureDir as e, getGroupedEntries as g, pluginName as p };
64
+ export { getCacheDir as a, ensureDir as b, escapeStringRegexp as e, getGroupedEntries as g, pluginName as p };
@@ -2,12 +2,14 @@
2
2
 
3
3
  const fs = require('node:fs/promises');
4
4
  const path = require('node:path');
5
+ const process = require('node:process');
5
6
  const shared = require('@tailwindcss-mangle/shared');
6
7
 
7
8
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
8
9
 
9
10
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
10
11
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
12
+ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
11
13
 
12
14
  const pluginName = "unplugin-tailwindcss-mangle";
13
15
 
@@ -54,7 +56,7 @@ function getGroupedEntries(entries, options = {
54
56
  }
55
57
  return groupedEntries;
56
58
  }
57
- function getCacheDir(basedir = process.cwd()) {
59
+ function getCacheDir(basedir = process__default.cwd()) {
58
60
  return path__default.resolve(basedir, "node_modules/.cache", pluginName);
59
61
  }
60
62
  async function ensureDir(p) {
package/dist/utils.cjs CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  require('node:fs/promises');
4
4
  require('node:path');
5
+ require('node:process');
5
6
  const shared = require('@tailwindcss-mangle/shared');
6
- const utils = require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
7
+ const utils = require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
7
8
 
8
9
 
9
10
 
package/dist/utils.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import 'node:fs/promises';
2
2
  import 'node:path';
3
+ import 'node:process';
3
4
  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';
5
+ export { b as ensureDir, e as escapeStringRegexp, a as getCacheDir, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
package/dist/vite.cjs CHANGED
@@ -1,12 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
4
  require('unplugin');
5
+ require('node:path');
7
6
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
7
+ require('is-css-request');
8
+ require('@rollup/pluginutils');
9
+ require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
10
+ require('node:fs/promises');
11
+ require('node:process');
10
12
  require('@tailwindcss-mangle/shared');
11
13
 
12
14
  const vite = index.vite;
package/dist/vite.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/vite.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/vite.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/vite.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
2
  import 'unplugin';
3
+ import 'node:path';
5
4
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
5
+ import 'is-css-request';
6
+ import '@rollup/pluginutils';
7
+ import './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
8
+ import 'node:fs/promises';
9
+ import 'node:process';
8
10
  import '@tailwindcss-mangle/shared';
9
11
 
10
12
  const vite = unplugin.vite;
package/dist/webpack.cjs CHANGED
@@ -1,12 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
4
  require('unplugin');
5
+ require('node:path');
7
6
  require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
7
+ require('is-css-request');
8
+ require('@rollup/pluginutils');
9
+ require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
10
+ require('node:fs/promises');
11
+ require('node:process');
10
12
  require('@tailwindcss-mangle/shared');
11
13
 
12
14
  const webpack = index.webpack;
@@ -1,6 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
5
5
 
6
6
  export { _default as default };
@@ -1,6 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
5
5
 
6
6
  export { _default as default };
package/dist/webpack.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
5
5
 
6
6
  export { _default as default };
package/dist/webpack.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
2
  import 'unplugin';
3
+ import 'node:path';
5
4
  import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
5
+ import 'is-css-request';
6
+ import '@rollup/pluginutils';
7
+ import './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
8
+ import 'node:fs/promises';
9
+ import 'node:process';
8
10
  import '@tailwindcss-mangle/shared';
9
11
 
10
12
  const webpack = unplugin.webpack;
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.1",
4
4
  "description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
5
5
  "author": "SonOfMagic <qq1324318532@gmail.com>",
6
6
  "license": "MIT",
@@ -43,16 +43,6 @@
43
43
  "import": "./dist/esbuild.mjs",
44
44
  "require": "./dist/esbuild.cjs"
45
45
  },
46
- "./nuxt": {
47
- "types": "./dist/nuxt.d.ts",
48
- "import": "./dist/nuxt.mjs",
49
- "require": "./dist/nuxt.cjs"
50
- },
51
- "./utils": {
52
- "types": "./dist/utils.d.ts",
53
- "import": "./dist/utils.mjs",
54
- "require": "./dist/utils.cjs"
55
- },
56
46
  "./*": "./*"
57
47
  },
58
48
  "main": "./dist/index.cjs",
@@ -70,11 +60,13 @@
70
60
  "dist"
71
61
  ],
72
62
  "dependencies": {
63
+ "@rollup/pluginutils": "^5.1.0",
64
+ "is-css-request": "^1.0.1",
73
65
  "magic-string": "^0.30.10",
74
- "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"
66
+ "unplugin": "^1.11.0",
67
+ "@tailwindcss-mangle/shared": "^3.0.0",
68
+ "@tailwindcss-mangle/config": "^3.0.0",
69
+ "@tailwindcss-mangle/core": "^3.0.0"
78
70
  },
79
71
  "publishConfig": {
80
72
  "access": "public",
@@ -82,7 +74,7 @@
82
74
  },
83
75
  "devDependencies": {
84
76
  "@types/babel__helper-plugin-utils": "^7.10.3",
85
- "astro": "^4.10.3",
77
+ "astro": "^4.11.5",
86
78
  "css-loader": "^7.1.2",
87
79
  "html-webpack-plugin": "^5.6.0",
88
80
  "mini-css-extract-plugin": "^2.9.0",
@@ -90,10 +82,10 @@
90
82
  "postcss": "^8.4.38",
91
83
  "postcss-loader": "^8.1.1",
92
84
  "tailwindcss": "^3.4.4",
93
- "vite": "^5.3.1",
94
- "webpack": "^5.92.0",
85
+ "vite": "^5.3.3",
86
+ "webpack": "^5.93.0",
95
87
  "webpack-build-utils": "^0.0.7",
96
- "tailwindcss-patch": "^3.0.1"
88
+ "tailwindcss-patch": "^3.0.2"
97
89
  },
98
90
  "scripts": {
99
91
  "dev": "unbuild --sourcemap",
package/dist/nuxt.cjs DELETED
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- const index = require('./index.cjs');
4
- require('node:path');
5
- require('node:fs/promises');
6
- require('unplugin');
7
- require('@tailwindcss-mangle/core');
8
- require('magic-string');
9
- require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
- require('@tailwindcss-mangle/shared');
11
-
12
- function nuxt(options = {}, nuxt) {
13
- nuxt.hook("webpack:config", (config) => {
14
- config.plugins = config.plugins || [];
15
- config.plugins.unshift(index.webpack(options));
16
- });
17
- nuxt.hook("vite:extendConfig", (config) => {
18
- config.plugins = config.plugins || [];
19
- config.plugins.push(index.vite(options));
20
- });
21
- }
22
-
23
- module.exports = nuxt;
package/dist/nuxt.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
-
3
- declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
-
5
- export { export_default as default };
package/dist/nuxt.d.mts DELETED
@@ -1,5 +0,0 @@
1
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
-
3
- declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
-
5
- export { export_default as default };
package/dist/nuxt.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
-
3
- declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
-
5
- export { export_default as default };
package/dist/nuxt.mjs DELETED
@@ -1,21 +0,0 @@
1
- import unplugin from './index.mjs';
2
- import 'node:path';
3
- import 'node:fs/promises';
4
- import 'unplugin';
5
- import '@tailwindcss-mangle/core';
6
- import 'magic-string';
7
- import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
- import '@tailwindcss-mangle/shared';
9
-
10
- function nuxt(options = {}, nuxt) {
11
- nuxt.hook("webpack:config", (config) => {
12
- config.plugins = config.plugins || [];
13
- config.plugins.unshift(unplugin.webpack(options));
14
- });
15
- nuxt.hook("vite:extendConfig", (config) => {
16
- config.plugins = config.plugins || [];
17
- config.plugins.push(unplugin.vite(options));
18
- });
19
- }
20
-
21
- export { nuxt as default };