weapp-tailwindcss 3.0.3 → 3.0.4

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/README.md CHANGED
@@ -21,8 +21,12 @@
21
21
  [![test](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml)
22
22
  [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
23
23
 
24
- > `小程序` + `tailwindcss` 全方面解决方案
25
- > 想试试在小程序里使用 `CSS-in-JS` 思想? 👉🏻👉🏻试试 [`weapp-pandacss`](https://github.com/sonofmagic/weapp-pandacss)
24
+ > 降低开发维护成本,提升开发效率的 `小程序` `tailwindcss` 全方面解决方案
25
+ >
26
+ > 我的其他项目:
27
+ > `CSS UI` 生成器 [`@icestack/ui`](https://ui.icebreaker.top/zh-CN) 已经发布,快来用它管理你的`CSS` 组件吧!
28
+ >
29
+ > 想试试在小程序里使用**编译时**`CSS-in-JS` 工具? 👉🏻👉🏻试试 [`weapp-pandacss`](https://github.com/sonofmagic/weapp-pandacss)
26
30
 
27
31
  \[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档]('./v1.md')\]
28
32
 
@@ -0,0 +1,8 @@
1
+ import type { Compiler } from 'webpack4';
2
+ import type { AppType, UserDefinedOptions, InternalUserDefinedOptions, IBaseWebpackPlugin } from "../../../types";
3
+ export declare class UnifiedWebpackPluginV4 implements IBaseWebpackPlugin {
4
+ options: InternalUserDefinedOptions;
5
+ appType?: AppType;
6
+ constructor(options?: UserDefinedOptions);
7
+ apply(compiler: Compiler): void;
8
+ }
package/dist/cli.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var options = require('./options-MDCr-9Qn.js');
3
+ var semver = require('semver');
4
+ var options = require('./options-N9g3FpWO.js');
5
+ var index = require('./index-Fkmyt0Rc.js');
4
6
  require('magic-string');
5
7
  require('./replace.js');
6
8
  require('@weapp-core/escape');
@@ -15,20 +17,27 @@ require('./defu-KWuJnZLV.js');
15
17
  require('@babel/types');
16
18
  require('htmlparser2');
17
19
  require('postcss');
18
- require('./postcss-bdPbDgs7.js');
19
- require('@csstools/postcss-is-pseudo-class');
20
- require('postcss-rem-to-responsive-pixel');
21
- require('postcss-selector-parser');
22
20
  require('node:path');
23
21
  require('node:fs');
24
- require('semver');
25
22
  require('tailwindcss-patch');
26
23
  require('@tailwindcss-mangle/shared');
27
24
  require('lru-cache');
28
25
  require('md5');
26
+ require('@csstools/postcss-is-pseudo-class');
27
+ require('postcss-rem-to-responsive-pixel');
28
+ require('postcss-selector-parser');
29
+
30
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
31
+
32
+ var semver__default = /*#__PURE__*/_interopDefaultCompat(semver);
29
33
 
30
34
  const args = process.argv.slice(2);
31
- if (args[0] === 'patch') {
35
+ if (semver__default["default"].lt(process.versions.node, index.WEAPP_TW_REQUIRED_NODE_VERSION)) {
36
+ console.error(`You are using Node.js ${process.versions.node}. For weapp-tailwindcss, Node.js version >= v${index.WEAPP_TW_REQUIRED_NODE_VERSION} is required.`);
37
+ process.exit(1);
38
+ }
39
+ const command = args[0];
40
+ if (command === 'patch') {
32
41
  const options$1 = options.getOptions();
33
42
  const patch = options.createPatch(options$1.supportCustomLengthUnitsPatch);
34
43
  patch();
package/dist/cli.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { g as getOptions, c as createPatch } from './options-9bBYg22L.mjs';
1
+ import semver from 'semver';
2
+ import { g as getOptions, a as createPatch } from './options-6YPFqoRJ.mjs';
3
+ import { W as WEAPP_TW_REQUIRED_NODE_VERSION } from './index-_74RBzwy.mjs';
2
4
  import 'magic-string';
3
5
  import './replace.mjs';
4
6
  import '@weapp-core/escape';
@@ -13,20 +15,23 @@ import './defu-ms_ZBCiB.mjs';
13
15
  import '@babel/types';
14
16
  import 'htmlparser2';
15
17
  import 'postcss';
16
- import './postcss-MxkGjr8g.mjs';
17
- import '@csstools/postcss-is-pseudo-class';
18
- import 'postcss-rem-to-responsive-pixel';
19
- import 'postcss-selector-parser';
20
18
  import 'node:path';
21
19
  import 'node:fs';
22
- import 'semver';
23
20
  import 'tailwindcss-patch';
24
21
  import '@tailwindcss-mangle/shared';
25
22
  import 'lru-cache';
26
23
  import 'md5';
24
+ import '@csstools/postcss-is-pseudo-class';
25
+ import 'postcss-rem-to-responsive-pixel';
26
+ import 'postcss-selector-parser';
27
27
 
28
28
  const args = process.argv.slice(2);
29
- if (args[0] === 'patch') {
29
+ if (semver.lt(process.versions.node, WEAPP_TW_REQUIRED_NODE_VERSION)) {
30
+ console.error(`You are using Node.js ${process.versions.node}. For weapp-tailwindcss, Node.js version >= v${WEAPP_TW_REQUIRED_NODE_VERSION} is required.`);
31
+ process.exit(1);
32
+ }
33
+ const command = args[0];
34
+ if (command === 'patch') {
30
35
  const options = getOptions();
31
36
  const patch = createPatch(options.supportCustomLengthUnitsPatch);
32
37
  patch();
@@ -4,3 +4,4 @@ export declare const ManglePluginHooks = "ManglePluginHooks";
4
4
  export declare const WeappTailwindcssWebpackPluginOptimizeChunkAssetsHooks = "WeappTailwindcssWebpackPluginOptimizeChunkAssetsHooks";
5
5
  export declare const pluginName = "weapp-tailwindcss-webpack-plugin";
6
6
  export declare const vitePluginName = "vite-plugin-uni-app-weapp-tailwindcss-adaptor";
7
+ export declare const WEAPP_TW_REQUIRED_NODE_VERSION = "16.6.0";
package/dist/core.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-MDCr-9Qn.js');
5
+ var options = require('./options-N9g3FpWO.js');
6
6
  require('magic-string');
7
7
  require('./replace.js');
8
8
  require('@weapp-core/escape');
@@ -17,7 +17,7 @@ require('./defu-KWuJnZLV.js');
17
17
  require('@babel/types');
18
18
  require('htmlparser2');
19
19
  require('postcss');
20
- require('./postcss-bdPbDgs7.js');
20
+ require('./index-Fkmyt0Rc.js');
21
21
  require('@csstools/postcss-is-pseudo-class');
22
22
  require('postcss-rem-to-responsive-pixel');
23
23
  require('postcss-selector-parser');
package/dist/core.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-9bBYg22L.mjs';
1
+ import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-6YPFqoRJ.mjs';
2
2
  import 'magic-string';
3
3
  import './replace.mjs';
4
4
  import '@weapp-core/escape';
@@ -13,7 +13,7 @@ import './defu-ms_ZBCiB.mjs';
13
13
  import '@babel/types';
14
14
  import 'htmlparser2';
15
15
  import 'postcss';
16
- import './postcss-MxkGjr8g.mjs';
16
+ import './index-_74RBzwy.mjs';
17
17
  import '@csstools/postcss-is-pseudo-class';
18
18
  import 'postcss-rem-to-responsive-pixel';
19
19
  import 'postcss-selector-parser';
@@ -4,7 +4,7 @@ var plugin = require('tailwindcss/plugin');
4
4
  var constants = require('../constants-EVxkHOXL.js');
5
5
  var defu = require('../defu-KWuJnZLV.js');
6
6
 
7
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
8
 
9
9
  var plugin__default = /*#__PURE__*/_interopDefaultCompat(plugin);
10
10
 
package/dist/gulp.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var options = require('./options-MDCr-9Qn.js');
6
- var stream = require('node:stream');
5
+ var index = require('./index-8OJKpYld.js');
6
+ require('./options-N9g3FpWO.js');
7
7
  require('magic-string');
8
8
  require('./replace.js');
9
9
  require('@weapp-core/escape');
@@ -18,7 +18,7 @@ require('./defu-KWuJnZLV.js');
18
18
  require('@babel/types');
19
19
  require('htmlparser2');
20
20
  require('postcss');
21
- require('./postcss-bdPbDgs7.js');
21
+ require('./index-Fkmyt0Rc.js');
22
22
  require('@csstools/postcss-is-pseudo-class');
23
23
  require('postcss-rem-to-responsive-pixel');
24
24
  require('postcss-selector-parser');
@@ -29,69 +29,8 @@ require('tailwindcss-patch');
29
29
  require('@tailwindcss-mangle/shared');
30
30
  require('lru-cache');
31
31
  require('md5');
32
+ require('node:stream');
32
33
 
33
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
34
34
 
35
- var stream__default = /*#__PURE__*/_interopDefaultCompat(stream);
36
35
 
37
- const Transform = stream__default["default"].Transform;
38
- function createPlugins(options$1 = {}) {
39
- const opts = options.getOptions(options$1);
40
- const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
41
- let runtimeSet = new Set();
42
- patch === null || patch === void 0 ? void 0 : patch();
43
- const twPatcher = options.createTailwindcssPatcher();
44
- function transformWxss() {
45
- const transformStream = new Transform({ objectMode: true });
46
- transformStream._transform = function (file, encoding, callback) {
47
- return options.__awaiter(this, void 0, void 0, function* () {
48
- runtimeSet = twPatcher.getClassSet({
49
- basedir: tailwindcssBasedir
50
- });
51
- setMangleRuntimeSet(runtimeSet);
52
- const error = null;
53
- if (file.contents) {
54
- const code = yield styleHandler(file.contents.toString(), {
55
- isMainChunk: true
56
- });
57
- file.contents = Buffer.from(code);
58
- }
59
- callback(error, file);
60
- });
61
- };
62
- return transformStream;
63
- }
64
- function transformJs() {
65
- const transformStream = new Transform({ objectMode: true });
66
- transformStream._transform = function (file, encoding, callback) {
67
- const error = null;
68
- if (file.contents) {
69
- const { code } = jsHandler(file.contents.toString(), runtimeSet);
70
- file.contents = Buffer.from(code);
71
- }
72
- callback(error, file);
73
- };
74
- return transformStream;
75
- }
76
- function transformWxml() {
77
- const transformStream = new Transform({ objectMode: true });
78
- transformStream._transform = function (file, encoding, callback) {
79
- const error = null;
80
- if (file.contents) {
81
- const code = templateHandler(file.contents.toString(), {
82
- runtimeSet
83
- });
84
- file.contents = Buffer.from(code);
85
- }
86
- callback(error, file);
87
- };
88
- return transformStream;
89
- }
90
- return {
91
- transformWxss,
92
- transformWxml,
93
- transformJs
94
- };
95
- }
96
-
97
- exports.createPlugins = createPlugins;
36
+ exports.createPlugins = index.createPlugins;
package/dist/gulp.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-9bBYg22L.mjs';
2
- import stream from 'node:stream';
1
+ export { c as createPlugins } from './index-u-U9HdG6.mjs';
2
+ import './options-6YPFqoRJ.mjs';
3
3
  import 'magic-string';
4
4
  import './replace.mjs';
5
5
  import '@weapp-core/escape';
@@ -14,7 +14,7 @@ import './defu-ms_ZBCiB.mjs';
14
14
  import '@babel/types';
15
15
  import 'htmlparser2';
16
16
  import 'postcss';
17
- import './postcss-MxkGjr8g.mjs';
17
+ import './index-_74RBzwy.mjs';
18
18
  import '@csstools/postcss-is-pseudo-class';
19
19
  import 'postcss-rem-to-responsive-pixel';
20
20
  import 'postcss-selector-parser';
@@ -25,65 +25,4 @@ import 'tailwindcss-patch';
25
25
  import '@tailwindcss-mangle/shared';
26
26
  import 'lru-cache';
27
27
  import 'md5';
28
-
29
- const Transform = stream.Transform;
30
- function createPlugins(options = {}) {
31
- const opts = getOptions(options);
32
- const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
33
- let runtimeSet = new Set();
34
- patch === null || patch === void 0 ? void 0 : patch();
35
- const twPatcher = createTailwindcssPatcher();
36
- function transformWxss() {
37
- const transformStream = new Transform({ objectMode: true });
38
- transformStream._transform = function (file, encoding, callback) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- runtimeSet = twPatcher.getClassSet({
41
- basedir: tailwindcssBasedir
42
- });
43
- setMangleRuntimeSet(runtimeSet);
44
- const error = null;
45
- if (file.contents) {
46
- const code = yield styleHandler(file.contents.toString(), {
47
- isMainChunk: true
48
- });
49
- file.contents = Buffer.from(code);
50
- }
51
- callback(error, file);
52
- });
53
- };
54
- return transformStream;
55
- }
56
- function transformJs() {
57
- const transformStream = new Transform({ objectMode: true });
58
- transformStream._transform = function (file, encoding, callback) {
59
- const error = null;
60
- if (file.contents) {
61
- const { code } = jsHandler(file.contents.toString(), runtimeSet);
62
- file.contents = Buffer.from(code);
63
- }
64
- callback(error, file);
65
- };
66
- return transformStream;
67
- }
68
- function transformWxml() {
69
- const transformStream = new Transform({ objectMode: true });
70
- transformStream._transform = function (file, encoding, callback) {
71
- const error = null;
72
- if (file.contents) {
73
- const code = templateHandler(file.contents.toString(), {
74
- runtimeSet
75
- });
76
- file.contents = Buffer.from(code);
77
- }
78
- callback(error, file);
79
- };
80
- return transformStream;
81
- }
82
- return {
83
- transformWxss,
84
- transformWxml,
85
- transformJs
86
- };
87
- }
88
-
89
- export { createPlugins };
28
+ import 'node:stream';
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ var options = require('./options-N9g3FpWO.js');
4
+ var stream = require('node:stream');
5
+
6
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
+
8
+ var stream__default = /*#__PURE__*/_interopDefaultCompat(stream);
9
+
10
+ const Transform = stream__default["default"].Transform;
11
+ function createPlugins(options$1 = {}) {
12
+ const opts = options.getOptions(options$1);
13
+ const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
14
+ let runtimeSet = new Set();
15
+ patch === null || patch === void 0 ? void 0 : patch();
16
+ const twPatcher = options.createTailwindcssPatcher();
17
+ function transformWxss() {
18
+ const transformStream = new Transform({ objectMode: true });
19
+ transformStream._transform = function (file, encoding, callback) {
20
+ return options.__awaiter(this, void 0, void 0, function* () {
21
+ runtimeSet = twPatcher.getClassSet({
22
+ basedir: tailwindcssBasedir
23
+ });
24
+ setMangleRuntimeSet(runtimeSet);
25
+ const error = null;
26
+ if (file.contents) {
27
+ const code = yield styleHandler(file.contents.toString(), {
28
+ isMainChunk: true
29
+ });
30
+ file.contents = Buffer.from(code);
31
+ }
32
+ callback(error, file);
33
+ });
34
+ };
35
+ return transformStream;
36
+ }
37
+ function transformJs() {
38
+ const transformStream = new Transform({ objectMode: true });
39
+ transformStream._transform = function (file, encoding, callback) {
40
+ const error = null;
41
+ if (file.contents) {
42
+ const { code } = jsHandler(file.contents.toString(), runtimeSet);
43
+ file.contents = Buffer.from(code);
44
+ }
45
+ callback(error, file);
46
+ };
47
+ return transformStream;
48
+ }
49
+ function transformWxml() {
50
+ const transformStream = new Transform({ objectMode: true });
51
+ transformStream._transform = function (file, encoding, callback) {
52
+ const error = null;
53
+ if (file.contents) {
54
+ const code = templateHandler(file.contents.toString(), {
55
+ runtimeSet
56
+ });
57
+ file.contents = Buffer.from(code);
58
+ }
59
+ callback(error, file);
60
+ };
61
+ return transformStream;
62
+ }
63
+ return {
64
+ transformWxss,
65
+ transformWxml,
66
+ transformJs
67
+ };
68
+ }
69
+
70
+ exports.createPlugins = createPlugins;
@@ -6,7 +6,7 @@ var selectorParser = require('postcss-selector-parser');
6
6
  var shared = require('./shared-AxeHlAoJ.js');
7
7
  var postcss = require('postcss');
8
8
 
9
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
10
10
 
11
11
  var postcssIsPseudoClass__default = /*#__PURE__*/_interopDefaultCompat(postcssIsPseudoClass);
12
12
  var postcssRem2rpx__default = /*#__PURE__*/_interopDefaultCompat(postcssRem2rpx);
@@ -380,6 +380,7 @@ function commonChunkPreflight(node, options) {
380
380
  const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
381
381
  const pluginName = 'weapp-tailwindcss-webpack-plugin';
382
382
  const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
383
+ const WEAPP_TW_REQUIRED_NODE_VERSION = '16.6.0';
383
384
 
384
385
  function isAtMediaHover(atRule) {
385
386
  return /media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name) || (atRule.name === 'media' && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params));
@@ -486,6 +487,7 @@ function getPlugins(options) {
486
487
  return plugins;
487
488
  }
488
489
 
490
+ exports.WEAPP_TW_REQUIRED_NODE_VERSION = WEAPP_TW_REQUIRED_NODE_VERSION;
489
491
  exports.getPlugins = getPlugins;
490
492
  exports.pluginName = pluginName;
491
493
  exports.postcssWeappTailwindcssPostPlugin = postcssWeappTailwindcssPostPlugin;
@@ -0,0 +1,142 @@
1
+ 'use strict';
2
+
3
+ var options = require('./options-N9g3FpWO.js');
4
+ var index = require('./index-Fkmyt0Rc.js');
5
+ var defaults = require('./defaults-QOAV8NSV.js');
6
+ var index$1 = require('./index-juOeq2Kt.js');
7
+
8
+ const debug = index$1.createDebug('generateBundle: ');
9
+ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
10
+ if (options$1.customReplaceDictionary === undefined) {
11
+ options$1.customReplaceDictionary = 'simple';
12
+ }
13
+ const opts = options.getOptions(options$1);
14
+ const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
15
+ if (disabled) {
16
+ return;
17
+ }
18
+ patch === null || patch === void 0 ? void 0 : patch();
19
+ const twPatcher = options.createTailwindcssPatcher();
20
+ onLoad();
21
+ return {
22
+ name: index.vitePluginName,
23
+ enforce: 'post',
24
+ generateBundle(opt, bundle) {
25
+ return options.__awaiter(this, void 0, void 0, function* () {
26
+ debug('start');
27
+ onStart();
28
+ const entries = Object.entries(bundle);
29
+ const groupedEntries = defaults.getGroupedEntries(entries, opts);
30
+ const runtimeSet = twPatcher.getClassSet({
31
+ basedir: tailwindcssBasedir
32
+ });
33
+ setMangleRuntimeSet(runtimeSet);
34
+ debug('get runtimeSet, class count: %d', runtimeSet.size);
35
+ if (Array.isArray(groupedEntries.html)) {
36
+ let noCachedCount = 0;
37
+ for (let i = 0; i < groupedEntries.html.length; i++) {
38
+ const [file, originalSource] = groupedEntries.html[i];
39
+ const oldVal = originalSource.source.toString();
40
+ const hash = cache.computeHash(oldVal);
41
+ cache.calcHashValueChanged(file, hash);
42
+ yield cache.process(file, () => {
43
+ const source = cache.get(file);
44
+ if (source) {
45
+ originalSource.source = source;
46
+ debug('html cache hit: %s', file);
47
+ }
48
+ else {
49
+ return false;
50
+ }
51
+ }, () => {
52
+ originalSource.source = templateHandler(oldVal, {
53
+ runtimeSet
54
+ });
55
+ onUpdate(file, oldVal, originalSource.source);
56
+ debug('html handle: %s', file);
57
+ noCachedCount++;
58
+ return {
59
+ key: file,
60
+ source: originalSource.source
61
+ };
62
+ });
63
+ }
64
+ debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
65
+ }
66
+ if (Array.isArray(groupedEntries.js)) {
67
+ let noCachedCount = 0;
68
+ for (let i = 0; i < groupedEntries.js.length; i++) {
69
+ const [file, originalSource] = groupedEntries.js[i];
70
+ const rawSource = originalSource.code;
71
+ const hash = cache.computeHash(rawSource);
72
+ cache.calcHashValueChanged(file, hash);
73
+ yield cache.process(file, () => {
74
+ const source = cache.get(file);
75
+ if (source) {
76
+ originalSource.code = source;
77
+ debug('js cache hit: %s', file);
78
+ }
79
+ else {
80
+ return false;
81
+ }
82
+ }, () => {
83
+ const mapFilename = file + '.map';
84
+ const hasMap = Boolean(bundle[mapFilename]);
85
+ const { code, map } = jsHandler(rawSource, runtimeSet, {
86
+ generateMap: hasMap
87
+ });
88
+ originalSource.code = code;
89
+ onUpdate(file, rawSource, code);
90
+ debug('js handle: %s', file);
91
+ noCachedCount++;
92
+ if (hasMap && map) {
93
+ bundle[mapFilename].source = map.toString();
94
+ }
95
+ return {
96
+ key: file,
97
+ source: code
98
+ };
99
+ });
100
+ }
101
+ debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
102
+ }
103
+ if (Array.isArray(groupedEntries.css)) {
104
+ let noCachedCount = 0;
105
+ for (let i = 0; i < groupedEntries.css.length; i++) {
106
+ const [file, originalSource] = groupedEntries.css[i];
107
+ const rawSource = originalSource.source.toString();
108
+ const hash = cache.computeHash(rawSource);
109
+ cache.calcHashValueChanged(file, hash);
110
+ yield cache.process(file, () => {
111
+ const source = cache.get(file);
112
+ if (source) {
113
+ originalSource.source = source;
114
+ debug('css cache hit: %s', file);
115
+ }
116
+ else {
117
+ return false;
118
+ }
119
+ }, () => options.__awaiter(this, void 0, void 0, function* () {
120
+ const css = yield styleHandler(rawSource, {
121
+ isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
122
+ });
123
+ originalSource.source = css;
124
+ onUpdate(file, rawSource, css);
125
+ debug('css handle: %s', file);
126
+ noCachedCount++;
127
+ return {
128
+ key: file,
129
+ source: css
130
+ };
131
+ }));
132
+ }
133
+ debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
134
+ }
135
+ onEnd();
136
+ debug('end');
137
+ });
138
+ }
139
+ };
140
+ }
141
+
142
+ exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;