weapp-tailwindcss 2.9.2 → 2.9.3
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 +13 -9
- package/dist/cache/index.d.ts +5 -2
- package/dist/cli.js +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/gulp.js +15 -11
- package/dist/gulp.mjs +15 -11
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{options-9dd8de2e.js → options-09ebba08.js} +50 -11
- package/dist/{options-e1a9fdd3.mjs → options-63407615.mjs} +50 -12
- package/dist/postcss/index.d.ts +2 -2
- package/dist/types.d.ts +2 -1
- package/dist/vite.js +110 -106
- package/dist/vite.mjs +110 -106
- package/dist/webpack.js +15 -13
- package/dist/webpack.mjs +15 -13
- package/package.json +30 -26
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
> `小程序` + `tailwindcss` 全方面解决方案
|
|
25
25
|
> 想试试在小程序里使用 `CSS-in-JS` 思想? 👉🏻👉🏻试试 [`weapp-pandacss`](https://github.com/sonofmagic/weapp-pandacss)
|
|
26
26
|
|
|
27
|
-
\[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档](./v1.md)\]
|
|
27
|
+
\[[国内部署的文档地址](https://weapp-tw.icebreaker.top)\] \| \[[备用Github Page](https://sonofmagic.github.io/weapp-tailwindcss/)\] \| \[[1.x文档]('./v1.md')\]
|
|
28
28
|
|
|
29
29
|
- [Tips](#tips)
|
|
30
30
|
- [特性](#特性)
|
|
@@ -43,13 +43,15 @@
|
|
|
43
43
|
- [使用`hbuilderx` 进行构建和开发](#使用hbuilderx-进行构建和开发)
|
|
44
44
|
- [使用`tarojs`进行构建 `vscode`开发](#使用tarojs进行构建-vscode开发)
|
|
45
45
|
- [原生小程序开发模板](#原生小程序开发模板)
|
|
46
|
-
- [tailwindcss plugin](#tailwindcss-plugin)
|
|
47
|
-
- [
|
|
46
|
+
- [tailwindcss plugin / util](#tailwindcss-plugin--util)
|
|
47
|
+
- [weapp-pandacss](#weapp-pandacss)
|
|
48
48
|
- [Bugs \& Issues](#bugs--issues)
|
|
49
49
|
|
|
50
50
|
## Tips
|
|
51
51
|
|
|
52
|
-
自从 `2.3.3` 版本开始,我发布了一个额外的包叫 `weapp-tailwindcss`,它和 `weapp-tailwindcss-webpack-plugin` 代码版本完全一致,且保持发布版本的同步。以后可以都去安装 `weapp-tailwindcss` 这个包(当然现在 `webpack-plugin` 这个包也不会废弃,也会时刻保持版本的同步)。为什么要这么做的原因,主要是因为 `weapp-tailwindcss-webpack-plugin`
|
|
52
|
+
自从 `2.3.3` 版本开始,我发布了一个额外的包叫 `weapp-tailwindcss`,它和 `weapp-tailwindcss-webpack-plugin` 代码版本完全一致,且保持发布版本的同步。以后可以都去安装 `weapp-tailwindcss` 这个包(当然现在 `webpack-plugin` 这个包也不会废弃,也会时刻保持版本的同步)。为什么要这么做的原因,主要是因为 `weapp-tailwindcss-webpack-plugin` 这个名字,已经不适合描述现在这种,多插件并存的状态了,为了以后的发展就改了个名字。
|
|
53
|
+
|
|
54
|
+
前沿阅读: [What’s Tailwind Oxide Engine? The Next Evolution of Tailwind CSS](https://medium.com/@bomber.marek/whats-tailwind-oxide-engine-the-next-evolution-of-tailwind-css-32e7ef8e19a1),未来 `tailwindcss` 会切换到这个引擎来大幅加快构建和运行速度,当然等它发布正式版本的时候,我也会尽可能第一时间去进行兼容新的引擎。
|
|
53
55
|
|
|
54
56
|
## 特性
|
|
55
57
|
|
|
@@ -63,7 +65,7 @@
|
|
|
63
65
|
|
|
64
66
|
### 插件介绍
|
|
65
67
|
|
|
66
|
-
从 `weapp-tailwindcss/webpack` 导出的`UnifiedWebpackPluginV5` 是一个核心插件,所有使用 `
|
|
68
|
+
从 `weapp-tailwindcss/webpack` 导出的`UnifiedWebpackPluginV5` 是一个核心插件,所有使用 `webpack5` 进行打包的框架都可以使用它。
|
|
67
69
|
|
|
68
70
|
从 `weapp-tailwindcss/vite` 导出的`UnifiedViteWeappTailwindcssPlugin` 为 `vite` 专用插件,配置项和使用方式和 `webpack` 插件是一致的。
|
|
69
71
|
|
|
@@ -121,13 +123,15 @@
|
|
|
121
123
|
|
|
122
124
|
[weapp-native-mina-tailwindcss-template(webpack打包)](https://github.com/sonofmagic/weapp-native-mina-tailwindcss-template)
|
|
123
125
|
|
|
124
|
-
### tailwindcss plugin
|
|
126
|
+
### tailwindcss plugin / util
|
|
127
|
+
|
|
128
|
+
- [css-to-tailwindcss-plugin](./packages/css-to-tailwindcss-plugin/) transform your `css/scss` to `tailwindcss plugin`
|
|
125
129
|
|
|
126
|
-
[weapp-tailwindcss-children](https://github.com/sonofmagic/weapp-tailwindcss-children)
|
|
130
|
+
- [weapp-tailwindcss-children](https://github.com/sonofmagic/weapp-tailwindcss-children)
|
|
127
131
|
|
|
128
|
-
###
|
|
132
|
+
### weapp-pandacss
|
|
129
133
|
|
|
130
|
-
[
|
|
134
|
+
[weapp-pandacss](https://github.com/sonofmagic/weapp-pandacss) `CSS-in-JS` 编译时框架的小程序适配器
|
|
131
135
|
|
|
132
136
|
## Bugs & Issues
|
|
133
137
|
|
package/dist/cache/index.d.ts
CHANGED
|
@@ -18,10 +18,13 @@ export interface ICreateCacheReturnType {
|
|
|
18
18
|
set: <V extends CacheValue = sources.Source>(key: string, value: V) => this['instance'];
|
|
19
19
|
has: (key: string) => boolean;
|
|
20
20
|
calcHashValueChanged: (key: HashMapKey, hash: string) => this;
|
|
21
|
-
process: (key: string, callback: () => void | false
|
|
21
|
+
process: (key: string, callback: () => void | false | Promise<void | false>, fallback: () => void | {
|
|
22
22
|
key: string;
|
|
23
23
|
source: CacheValue;
|
|
24
|
-
}
|
|
24
|
+
} | Promise<void | {
|
|
25
|
+
key: string;
|
|
26
|
+
source: CacheValue;
|
|
27
|
+
}>) => void | Promise<void>;
|
|
25
28
|
}
|
|
26
29
|
declare function createCache(): ICreateCacheReturnType;
|
|
27
30
|
export { createCache };
|
package/dist/cli.js
CHANGED
package/dist/cli.mjs
CHANGED
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-09ebba08.js');
|
|
5
6
|
var stream = require('node:stream');
|
|
6
|
-
var options = require('./options-9dd8de2e.js');
|
|
7
7
|
require('micromatch');
|
|
8
8
|
require('magic-string');
|
|
9
9
|
require('./replace.js');
|
|
@@ -39,23 +39,27 @@ function createPlugins(options$1 = {}) {
|
|
|
39
39
|
options$1.customReplaceDictionary = 'simple';
|
|
40
40
|
}
|
|
41
41
|
const opts = options.getOptions(options$1);
|
|
42
|
-
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
42
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
|
|
43
43
|
let runtimeSet = new Set();
|
|
44
44
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
45
45
|
const twPatcher = options.createTailwindcssPatcher();
|
|
46
46
|
function transformWxss() {
|
|
47
47
|
const transformStream = new Transform({ objectMode: true });
|
|
48
48
|
transformStream._transform = function (file, encoding, callback) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (file.contents) {
|
|
53
|
-
const code = styleHandler(file.contents.toString(), {
|
|
54
|
-
isMainChunk: true
|
|
49
|
+
return options.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
runtimeSet = twPatcher.getClassSet({
|
|
51
|
+
basedir: tailwindcssBasedir
|
|
55
52
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
setMangleRuntimeSet(runtimeSet);
|
|
54
|
+
const error = null;
|
|
55
|
+
if (file.contents) {
|
|
56
|
+
const code = yield styleHandler(file.contents.toString(), {
|
|
57
|
+
isMainChunk: true
|
|
58
|
+
});
|
|
59
|
+
file.contents = Buffer.from(code);
|
|
60
|
+
}
|
|
61
|
+
callback(error, file);
|
|
62
|
+
});
|
|
59
63
|
};
|
|
60
64
|
return transformStream;
|
|
61
65
|
}
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-63407615.mjs';
|
|
1
2
|
import stream from 'node:stream';
|
|
2
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-e1a9fdd3.mjs';
|
|
3
3
|
import 'micromatch';
|
|
4
4
|
import 'magic-string';
|
|
5
5
|
import './replace.mjs';
|
|
@@ -31,23 +31,27 @@ function createPlugins(options = {}) {
|
|
|
31
31
|
options.customReplaceDictionary = 'simple';
|
|
32
32
|
}
|
|
33
33
|
const opts = getOptions(options);
|
|
34
|
-
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
34
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
|
|
35
35
|
let runtimeSet = new Set();
|
|
36
36
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
37
37
|
const twPatcher = createTailwindcssPatcher();
|
|
38
38
|
function transformWxss() {
|
|
39
39
|
const transformStream = new Transform({ objectMode: true });
|
|
40
40
|
transformStream._transform = function (file, encoding, callback) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (file.contents) {
|
|
45
|
-
const code = styleHandler(file.contents.toString(), {
|
|
46
|
-
isMainChunk: true
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
runtimeSet = twPatcher.getClassSet({
|
|
43
|
+
basedir: tailwindcssBasedir
|
|
47
44
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
setMangleRuntimeSet(runtimeSet);
|
|
46
|
+
const error = null;
|
|
47
|
+
if (file.contents) {
|
|
48
|
+
const code = yield styleHandler(file.contents.toString(), {
|
|
49
|
+
isMainChunk: true
|
|
50
|
+
});
|
|
51
|
+
file.contents = Buffer.from(code);
|
|
52
|
+
}
|
|
53
|
+
callback(error, file);
|
|
54
|
+
});
|
|
51
55
|
};
|
|
52
56
|
return transformStream;
|
|
53
57
|
}
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var webpack = require('./webpack.js');
|
|
6
6
|
var vite = require('./vite.js');
|
|
7
7
|
var gulp = require('./gulp.js');
|
|
8
|
-
require('
|
|
9
|
-
require('node:fs');
|
|
10
|
-
require('./options-9dd8de2e.js');
|
|
8
|
+
require('./options-09ebba08.js');
|
|
11
9
|
require('micromatch');
|
|
12
10
|
require('magic-string');
|
|
13
11
|
require('./replace.js');
|
|
@@ -25,6 +23,8 @@ require('postcss');
|
|
|
25
23
|
require('./postcss-8d7f67b4.js');
|
|
26
24
|
require('postcss-selector-parser');
|
|
27
25
|
require('@csstools/postcss-is-pseudo-class');
|
|
26
|
+
require('node:path');
|
|
27
|
+
require('node:fs');
|
|
28
28
|
require('semver');
|
|
29
29
|
require('tailwindcss-patch');
|
|
30
30
|
require('@tailwindcss-mangle/shared');
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export { UnifiedWebpackPluginV5 } from './webpack.mjs';
|
|
2
2
|
export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
|
|
3
3
|
export { createPlugins } from './gulp.mjs';
|
|
4
|
-
import '
|
|
5
|
-
import 'node:fs';
|
|
6
|
-
import './options-e1a9fdd3.mjs';
|
|
4
|
+
import './options-63407615.mjs';
|
|
7
5
|
import 'micromatch';
|
|
8
6
|
import 'magic-string';
|
|
9
7
|
import './replace.mjs';
|
|
@@ -21,6 +19,8 @@ import 'postcss';
|
|
|
21
19
|
import './postcss-55ed4d42.mjs';
|
|
22
20
|
import 'postcss-selector-parser';
|
|
23
21
|
import '@csstools/postcss-is-pseudo-class';
|
|
22
|
+
import 'node:path';
|
|
23
|
+
import 'node:fs';
|
|
24
24
|
import 'semver';
|
|
25
25
|
import 'tailwindcss-patch';
|
|
26
26
|
import '@tailwindcss-mangle/shared';
|
|
@@ -53,6 +53,38 @@ var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
|
53
53
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
54
54
|
var md5__default = /*#__PURE__*/_interopDefaultCompat(md5);
|
|
55
55
|
|
|
56
|
+
/******************************************************************************
|
|
57
|
+
Copyright (c) Microsoft Corporation.
|
|
58
|
+
|
|
59
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
60
|
+
purpose with or without fee is hereby granted.
|
|
61
|
+
|
|
62
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
63
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
64
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
65
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
66
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
67
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
68
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
69
|
+
***************************************************************************** */
|
|
70
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
74
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
75
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
76
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
77
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
78
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
79
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
84
|
+
var e = new Error(message);
|
|
85
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
86
|
+
};
|
|
87
|
+
|
|
56
88
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
57
89
|
function isValidSelector(selector = '') {
|
|
58
90
|
return validateFilterRE.test(selector);
|
|
@@ -491,7 +523,11 @@ function createTemplateHandler(options = {}) {
|
|
|
491
523
|
}
|
|
492
524
|
|
|
493
525
|
function styleHandler(rawSource, options) {
|
|
494
|
-
return
|
|
526
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
527
|
+
return (yield postcss__default["default"]([postcssIsPseudoClass__default["default"](), postcss$1.postcssWeappTailwindcss(options)])
|
|
528
|
+
.process(rawSource)
|
|
529
|
+
.async()).css;
|
|
530
|
+
});
|
|
495
531
|
}
|
|
496
532
|
function createStyleHandler(options) {
|
|
497
533
|
return (rawSource, opt) => {
|
|
@@ -748,17 +784,19 @@ function createCache() {
|
|
|
748
784
|
return instance.has(key);
|
|
749
785
|
},
|
|
750
786
|
process(key, callback, fallback) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
787
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
788
|
+
const hit = this.getHashValue(key);
|
|
789
|
+
if (hit && !hit.changed) {
|
|
790
|
+
const returnFlag = yield callback();
|
|
791
|
+
if (returnFlag !== false) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
756
794
|
}
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
795
|
+
const res = yield fallback();
|
|
796
|
+
if (res) {
|
|
797
|
+
this.set(res.key, res.source);
|
|
798
|
+
}
|
|
799
|
+
});
|
|
762
800
|
}
|
|
763
801
|
};
|
|
764
802
|
}
|
|
@@ -837,6 +875,7 @@ function getOptions(options = {}) {
|
|
|
837
875
|
return result;
|
|
838
876
|
}
|
|
839
877
|
|
|
878
|
+
exports.__awaiter = __awaiter;
|
|
840
879
|
exports.createPatch = createPatch;
|
|
841
880
|
exports.createTailwindcssPatcher = createTailwindcssPatcher;
|
|
842
881
|
exports.getOptions = getOptions;
|
|
@@ -21,6 +21,38 @@ import { ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/sh
|
|
|
21
21
|
import { LRUCache } from 'lru-cache';
|
|
22
22
|
import md5 from 'md5';
|
|
23
23
|
|
|
24
|
+
/******************************************************************************
|
|
25
|
+
Copyright (c) Microsoft Corporation.
|
|
26
|
+
|
|
27
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
28
|
+
purpose with or without fee is hereby granted.
|
|
29
|
+
|
|
30
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
31
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
32
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
33
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
34
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
35
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
36
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
37
|
+
***************************************************************************** */
|
|
38
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
42
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
43
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
44
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
45
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
46
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
47
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
52
|
+
var e = new Error(message);
|
|
53
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
54
|
+
};
|
|
55
|
+
|
|
24
56
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
25
57
|
function isValidSelector(selector = '') {
|
|
26
58
|
return validateFilterRE.test(selector);
|
|
@@ -459,7 +491,11 @@ function createTemplateHandler(options = {}) {
|
|
|
459
491
|
}
|
|
460
492
|
|
|
461
493
|
function styleHandler(rawSource, options) {
|
|
462
|
-
return
|
|
494
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
495
|
+
return (yield postcss([postcssIsPseudoClass(), postcssWeappTailwindcss(options)])
|
|
496
|
+
.process(rawSource)
|
|
497
|
+
.async()).css;
|
|
498
|
+
});
|
|
463
499
|
}
|
|
464
500
|
function createStyleHandler(options) {
|
|
465
501
|
return (rawSource, opt) => {
|
|
@@ -716,17 +752,19 @@ function createCache() {
|
|
|
716
752
|
return instance.has(key);
|
|
717
753
|
},
|
|
718
754
|
process(key, callback, fallback) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
755
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
756
|
+
const hit = this.getHashValue(key);
|
|
757
|
+
if (hit && !hit.changed) {
|
|
758
|
+
const returnFlag = yield callback();
|
|
759
|
+
if (returnFlag !== false) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
724
762
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
763
|
+
const res = yield fallback();
|
|
764
|
+
if (res) {
|
|
765
|
+
this.set(res.key, res.source);
|
|
766
|
+
}
|
|
767
|
+
});
|
|
730
768
|
}
|
|
731
769
|
};
|
|
732
770
|
}
|
|
@@ -805,4 +843,4 @@ function getOptions(options = {}) {
|
|
|
805
843
|
return result;
|
|
806
844
|
}
|
|
807
845
|
|
|
808
|
-
export { createTailwindcssPatcher as a, createPatch as c, getOptions as g };
|
|
846
|
+
export { __awaiter as _, createTailwindcssPatcher as a, createPatch as c, getOptions as g };
|
package/dist/postcss/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IStyleHandlerOptions } from "../types";
|
|
2
|
-
export declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): string
|
|
3
|
-
export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => string
|
|
2
|
+
export declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): Promise<string>;
|
|
3
|
+
export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<string>;
|
package/dist/types.d.ts
CHANGED
|
@@ -106,6 +106,7 @@ export interface UserDefinedOptions {
|
|
|
106
106
|
root?: string | false;
|
|
107
107
|
universal?: string | false;
|
|
108
108
|
};
|
|
109
|
+
tailwindcssBasedir?: string;
|
|
109
110
|
}
|
|
110
111
|
export type JsHandler = (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult;
|
|
111
112
|
export interface IMangleScopeContext {
|
|
@@ -137,7 +138,7 @@ export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobO
|
|
|
137
138
|
} & {
|
|
138
139
|
supportCustomLengthUnitsPatch: ILengthUnitsPatchOptions | false;
|
|
139
140
|
templateHandler: (rawSource: string, options?: ITemplateHandlerOptions) => string;
|
|
140
|
-
styleHandler: (rawSource: string, options: IStyleHandlerOptions) => string
|
|
141
|
+
styleHandler: (rawSource: string, options: IStyleHandlerOptions) => Promise<string>;
|
|
141
142
|
jsHandler: JsHandler;
|
|
142
143
|
escapeMap: Record<string, string>;
|
|
143
144
|
patch: () => void;
|
package/dist/vite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var options = require('./options-
|
|
5
|
+
var options = require('./options-09ebba08.js');
|
|
6
6
|
var postcss = require('./postcss-8d7f67b4.js');
|
|
7
7
|
var defaults = require('./defaults-b7341550.js');
|
|
8
8
|
var index = require('./index-aede98ce.js');
|
|
@@ -36,7 +36,7 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
|
|
36
36
|
options$1.customReplaceDictionary = 'simple';
|
|
37
37
|
}
|
|
38
38
|
const opts = options.getOptions(options$1);
|
|
39
|
-
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache } = opts;
|
|
39
|
+
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
|
|
40
40
|
if (disabled) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
@@ -47,115 +47,119 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
|
|
47
47
|
name: postcss.vitePluginName,
|
|
48
48
|
enforce: 'post',
|
|
49
49
|
generateBundle(opt, bundle) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
return options.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
debug('start');
|
|
52
|
+
onStart();
|
|
53
|
+
const entries = Object.entries(bundle);
|
|
54
|
+
const groupedEntries = defaults.getGroupedEntries(entries, opts);
|
|
55
|
+
const runtimeSet = twPatcher.getClassSet({
|
|
56
|
+
basedir: tailwindcssBasedir
|
|
57
|
+
});
|
|
58
|
+
setMangleRuntimeSet(runtimeSet);
|
|
59
|
+
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
60
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
61
|
+
let noCachedCount = 0;
|
|
62
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
63
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
64
|
+
const oldVal = originalSource.source.toString();
|
|
65
|
+
const hash = cache.computeHash(oldVal);
|
|
66
|
+
cache.calcHashValueChanged(file, hash);
|
|
67
|
+
yield cache.process(file, () => {
|
|
68
|
+
const source = cache.get(file);
|
|
69
|
+
if (source) {
|
|
70
|
+
originalSource.source = source;
|
|
71
|
+
debug('html cache hit: %s', file);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}, () => {
|
|
77
|
+
originalSource.source = templateHandler(oldVal, {
|
|
78
|
+
runtimeSet
|
|
79
|
+
});
|
|
80
|
+
onUpdate(file, oldVal, originalSource.source);
|
|
81
|
+
debug('html handle: %s', file);
|
|
82
|
+
noCachedCount++;
|
|
83
|
+
return {
|
|
84
|
+
key: file,
|
|
85
|
+
source: originalSource.source
|
|
86
|
+
};
|
|
76
87
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
noCachedCount++;
|
|
80
|
-
return {
|
|
81
|
-
key: file,
|
|
82
|
-
source: originalSource.source
|
|
83
|
-
};
|
|
84
|
-
});
|
|
88
|
+
}
|
|
89
|
+
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
85
90
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
92
|
+
let noCachedCount = 0;
|
|
93
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
94
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
95
|
+
const rawSource = originalSource.code;
|
|
96
|
+
const hash = cache.computeHash(rawSource);
|
|
97
|
+
cache.calcHashValueChanged(file, hash);
|
|
98
|
+
yield cache.process(file, () => {
|
|
99
|
+
const source = cache.get(file);
|
|
100
|
+
if (source) {
|
|
101
|
+
originalSource.code = source;
|
|
102
|
+
debug('js cache hit: %s', file);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}, () => {
|
|
108
|
+
const mapFilename = file + '.map';
|
|
109
|
+
const hasMap = Boolean(bundle[mapFilename]);
|
|
110
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
111
|
+
generateMap: hasMap
|
|
112
|
+
});
|
|
113
|
+
originalSource.code = code;
|
|
114
|
+
onUpdate(file, rawSource, code);
|
|
115
|
+
debug('js handle: %s', file);
|
|
116
|
+
noCachedCount++;
|
|
117
|
+
if (hasMap && map) {
|
|
118
|
+
bundle[mapFilename].source = map.toString();
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
key: file,
|
|
122
|
+
source: code
|
|
123
|
+
};
|
|
109
124
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
debug('js handle: %s', file);
|
|
113
|
-
noCachedCount++;
|
|
114
|
-
if (hasMap && map) {
|
|
115
|
-
bundle[mapFilename].source = map.toString();
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
key: file,
|
|
119
|
-
source: code
|
|
120
|
-
};
|
|
121
|
-
});
|
|
125
|
+
}
|
|
126
|
+
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
122
127
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
128
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
129
|
+
let noCachedCount = 0;
|
|
130
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
131
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
132
|
+
const rawSource = originalSource.source.toString();
|
|
133
|
+
const hash = cache.computeHash(rawSource);
|
|
134
|
+
cache.calcHashValueChanged(file, hash);
|
|
135
|
+
yield cache.process(file, () => {
|
|
136
|
+
const source = cache.get(file);
|
|
137
|
+
if (source) {
|
|
138
|
+
originalSource.source = source;
|
|
139
|
+
debug('css cache hit: %s', file);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const css = yield styleHandler(rawSource, {
|
|
146
|
+
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
147
|
+
});
|
|
148
|
+
originalSource.source = css;
|
|
149
|
+
onUpdate(file, rawSource, css);
|
|
150
|
+
debug('css handle: %s', file);
|
|
151
|
+
noCachedCount++;
|
|
152
|
+
return {
|
|
153
|
+
key: file,
|
|
154
|
+
source: css
|
|
155
|
+
};
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
154
159
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
debug('end');
|
|
160
|
+
onEnd();
|
|
161
|
+
debug('end');
|
|
162
|
+
});
|
|
159
163
|
}
|
|
160
164
|
};
|
|
161
165
|
}
|
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-
|
|
1
|
+
import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-63407615.mjs';
|
|
2
2
|
import { v as vitePluginName } from './postcss-55ed4d42.mjs';
|
|
3
3
|
import { g as getGroupedEntries } from './defaults-d2c66d23.mjs';
|
|
4
4
|
import { c as createDebug } from './index-84c7aa87.mjs';
|
|
@@ -32,7 +32,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
32
32
|
options.customReplaceDictionary = 'simple';
|
|
33
33
|
}
|
|
34
34
|
const opts = getOptions(options);
|
|
35
|
-
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache } = opts;
|
|
35
|
+
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
|
|
36
36
|
if (disabled) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
@@ -43,115 +43,119 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
43
43
|
name: vitePluginName,
|
|
44
44
|
enforce: 'post',
|
|
45
45
|
generateBundle(opt, bundle) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
debug('start');
|
|
48
|
+
onStart();
|
|
49
|
+
const entries = Object.entries(bundle);
|
|
50
|
+
const groupedEntries = getGroupedEntries(entries, opts);
|
|
51
|
+
const runtimeSet = twPatcher.getClassSet({
|
|
52
|
+
basedir: tailwindcssBasedir
|
|
53
|
+
});
|
|
54
|
+
setMangleRuntimeSet(runtimeSet);
|
|
55
|
+
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
56
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
57
|
+
let noCachedCount = 0;
|
|
58
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
59
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
60
|
+
const oldVal = originalSource.source.toString();
|
|
61
|
+
const hash = cache.computeHash(oldVal);
|
|
62
|
+
cache.calcHashValueChanged(file, hash);
|
|
63
|
+
yield cache.process(file, () => {
|
|
64
|
+
const source = cache.get(file);
|
|
65
|
+
if (source) {
|
|
66
|
+
originalSource.source = source;
|
|
67
|
+
debug('html cache hit: %s', file);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}, () => {
|
|
73
|
+
originalSource.source = templateHandler(oldVal, {
|
|
74
|
+
runtimeSet
|
|
75
|
+
});
|
|
76
|
+
onUpdate(file, oldVal, originalSource.source);
|
|
77
|
+
debug('html handle: %s', file);
|
|
78
|
+
noCachedCount++;
|
|
79
|
+
return {
|
|
80
|
+
key: file,
|
|
81
|
+
source: originalSource.source
|
|
82
|
+
};
|
|
72
83
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
noCachedCount++;
|
|
76
|
-
return {
|
|
77
|
-
key: file,
|
|
78
|
-
source: originalSource.source
|
|
79
|
-
};
|
|
80
|
-
});
|
|
84
|
+
}
|
|
85
|
+
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
81
86
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
87
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
88
|
+
let noCachedCount = 0;
|
|
89
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
90
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
91
|
+
const rawSource = originalSource.code;
|
|
92
|
+
const hash = cache.computeHash(rawSource);
|
|
93
|
+
cache.calcHashValueChanged(file, hash);
|
|
94
|
+
yield cache.process(file, () => {
|
|
95
|
+
const source = cache.get(file);
|
|
96
|
+
if (source) {
|
|
97
|
+
originalSource.code = source;
|
|
98
|
+
debug('js cache hit: %s', file);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}, () => {
|
|
104
|
+
const mapFilename = file + '.map';
|
|
105
|
+
const hasMap = Boolean(bundle[mapFilename]);
|
|
106
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
107
|
+
generateMap: hasMap
|
|
108
|
+
});
|
|
109
|
+
originalSource.code = code;
|
|
110
|
+
onUpdate(file, rawSource, code);
|
|
111
|
+
debug('js handle: %s', file);
|
|
112
|
+
noCachedCount++;
|
|
113
|
+
if (hasMap && map) {
|
|
114
|
+
bundle[mapFilename].source = map.toString();
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
key: file,
|
|
118
|
+
source: code
|
|
119
|
+
};
|
|
105
120
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
debug('js handle: %s', file);
|
|
109
|
-
noCachedCount++;
|
|
110
|
-
if (hasMap && map) {
|
|
111
|
-
bundle[mapFilename].source = map.toString();
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
key: file,
|
|
115
|
-
source: code
|
|
116
|
-
};
|
|
117
|
-
});
|
|
121
|
+
}
|
|
122
|
+
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
118
123
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
124
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
125
|
+
let noCachedCount = 0;
|
|
126
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
127
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
128
|
+
const rawSource = originalSource.source.toString();
|
|
129
|
+
const hash = cache.computeHash(rawSource);
|
|
130
|
+
cache.calcHashValueChanged(file, hash);
|
|
131
|
+
yield cache.process(file, () => {
|
|
132
|
+
const source = cache.get(file);
|
|
133
|
+
if (source) {
|
|
134
|
+
originalSource.source = source;
|
|
135
|
+
debug('css cache hit: %s', file);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
const css = yield styleHandler(rawSource, {
|
|
142
|
+
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
143
|
+
});
|
|
144
|
+
originalSource.source = css;
|
|
145
|
+
onUpdate(file, rawSource, css);
|
|
146
|
+
debug('css handle: %s', file);
|
|
147
|
+
noCachedCount++;
|
|
148
|
+
return {
|
|
149
|
+
key: file,
|
|
150
|
+
source: css
|
|
151
|
+
};
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
150
155
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
debug('end');
|
|
156
|
+
onEnd();
|
|
157
|
+
debug('end');
|
|
158
|
+
});
|
|
155
159
|
}
|
|
156
160
|
};
|
|
157
161
|
}
|
package/dist/webpack.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var options = require('./options-09ebba08.js');
|
|
5
6
|
var path = require('node:path');
|
|
6
7
|
var fs = require('node:fs');
|
|
7
|
-
var options = require('./options-9dd8de2e.js');
|
|
8
8
|
var postcss = require('./postcss-8d7f67b4.js');
|
|
9
9
|
var defaults = require('./defaults-b7341550.js');
|
|
10
10
|
var index = require('./index-aede98ce.js');
|
|
@@ -35,7 +35,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
35
35
|
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
36
36
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
37
37
|
|
|
38
|
-
const debug = index.createDebug('');
|
|
38
|
+
const debug = index.createDebug('processAssets: ');
|
|
39
39
|
class UnifiedWebpackPluginV5 {
|
|
40
40
|
constructor(options$1 = {}) {
|
|
41
41
|
if (options$1.customReplaceDictionary === undefined) {
|
|
@@ -45,7 +45,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
45
45
|
this.appType = this.options.appType;
|
|
46
46
|
}
|
|
47
47
|
apply(compiler) {
|
|
48
|
-
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache } = this.options;
|
|
48
|
+
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, tailwindcssBasedir } = this.options;
|
|
49
49
|
if (disabled) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
@@ -54,7 +54,9 @@ class UnifiedWebpackPluginV5 {
|
|
|
54
54
|
const { ConcatSource, RawSource } = sources;
|
|
55
55
|
const twPatcher = options.createTailwindcssPatcher();
|
|
56
56
|
function getClassSet() {
|
|
57
|
-
return twPatcher.getClassSet(
|
|
57
|
+
return twPatcher.getClassSet({
|
|
58
|
+
basedir: tailwindcssBasedir
|
|
59
|
+
});
|
|
58
60
|
}
|
|
59
61
|
onLoad();
|
|
60
62
|
const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path__default["default"].resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
@@ -76,10 +78,10 @@ class UnifiedWebpackPluginV5 {
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
});
|
|
79
|
-
compilation.hooks.processAssets.
|
|
81
|
+
compilation.hooks.processAssets.tapPromise({
|
|
80
82
|
name: postcss.pluginName,
|
|
81
83
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
82
|
-
}, (assets) => {
|
|
84
|
+
}, (assets) => options.__awaiter(this, void 0, void 0, function* () {
|
|
83
85
|
onStart();
|
|
84
86
|
debug('start');
|
|
85
87
|
for (const chunk of compilation.chunks) {
|
|
@@ -100,7 +102,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
100
102
|
const hash = cache.computeHash(rawSource);
|
|
101
103
|
const cacheKey = file;
|
|
102
104
|
cache.calcHashValueChanged(cacheKey, hash);
|
|
103
|
-
cache.process(cacheKey, () => {
|
|
105
|
+
yield cache.process(cacheKey, () => {
|
|
104
106
|
const source = cache.get(cacheKey);
|
|
105
107
|
if (source) {
|
|
106
108
|
compilation.updateAsset(file, source);
|
|
@@ -131,7 +133,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
131
133
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
132
134
|
const [file, originalSource] = groupedEntries.js[i];
|
|
133
135
|
const cacheKey = defaults.removeExt(file);
|
|
134
|
-
cache.process(cacheKey, () => {
|
|
136
|
+
yield cache.process(cacheKey, () => {
|
|
135
137
|
const source = cache.get(cacheKey);
|
|
136
138
|
if (source) {
|
|
137
139
|
compilation.updateAsset(file, source);
|
|
@@ -172,7 +174,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
172
174
|
const hash = cache.computeHash(rawSource);
|
|
173
175
|
const cacheKey = file;
|
|
174
176
|
cache.calcHashValueChanged(cacheKey, hash);
|
|
175
|
-
cache.process(cacheKey, () => {
|
|
177
|
+
yield cache.process(cacheKey, () => {
|
|
176
178
|
const source = cache.get(cacheKey);
|
|
177
179
|
if (source) {
|
|
178
180
|
compilation.updateAsset(file, source);
|
|
@@ -181,8 +183,8 @@ class UnifiedWebpackPluginV5 {
|
|
|
181
183
|
else {
|
|
182
184
|
return false;
|
|
183
185
|
}
|
|
184
|
-
}, () => {
|
|
185
|
-
const css = styleHandler(rawSource, {
|
|
186
|
+
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
const css = yield styleHandler(rawSource, {
|
|
186
188
|
isMainChunk: mainCssChunkMatcher(file, this.appType)
|
|
187
189
|
});
|
|
188
190
|
const source = new ConcatSource(css);
|
|
@@ -194,13 +196,13 @@ class UnifiedWebpackPluginV5 {
|
|
|
194
196
|
key: cacheKey,
|
|
195
197
|
source
|
|
196
198
|
};
|
|
197
|
-
});
|
|
199
|
+
}));
|
|
198
200
|
}
|
|
199
201
|
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
200
202
|
}
|
|
201
203
|
debug('end');
|
|
202
204
|
onEnd();
|
|
203
|
-
});
|
|
205
|
+
}));
|
|
204
206
|
});
|
|
205
207
|
}
|
|
206
208
|
}
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { g as getOptions, a as createTailwindcssPatcher, _ as __awaiter } from './options-63407615.mjs';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import fs from 'node:fs';
|
|
3
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-e1a9fdd3.mjs';
|
|
4
4
|
import { a as pluginName } from './postcss-55ed4d42.mjs';
|
|
5
5
|
import { g as getGroupedEntries, r as removeExt } from './defaults-d2c66d23.mjs';
|
|
6
6
|
import { c as createDebug } from './index-84c7aa87.mjs';
|
|
@@ -26,7 +26,7 @@ import 'md5';
|
|
|
26
26
|
import 'postcss-selector-parser';
|
|
27
27
|
import 'debug';
|
|
28
28
|
|
|
29
|
-
const debug = createDebug('');
|
|
29
|
+
const debug = createDebug('processAssets: ');
|
|
30
30
|
class UnifiedWebpackPluginV5 {
|
|
31
31
|
constructor(options = {}) {
|
|
32
32
|
if (options.customReplaceDictionary === undefined) {
|
|
@@ -36,7 +36,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
36
36
|
this.appType = this.options.appType;
|
|
37
37
|
}
|
|
38
38
|
apply(compiler) {
|
|
39
|
-
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache } = this.options;
|
|
39
|
+
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, tailwindcssBasedir } = this.options;
|
|
40
40
|
if (disabled) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
@@ -45,7 +45,9 @@ class UnifiedWebpackPluginV5 {
|
|
|
45
45
|
const { ConcatSource, RawSource } = sources;
|
|
46
46
|
const twPatcher = createTailwindcssPatcher();
|
|
47
47
|
function getClassSet() {
|
|
48
|
-
return twPatcher.getClassSet(
|
|
48
|
+
return twPatcher.getClassSet({
|
|
49
|
+
basedir: tailwindcssBasedir
|
|
50
|
+
});
|
|
49
51
|
}
|
|
50
52
|
onLoad();
|
|
51
53
|
const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path.resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
@@ -67,10 +69,10 @@ class UnifiedWebpackPluginV5 {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
|
-
compilation.hooks.processAssets.
|
|
72
|
+
compilation.hooks.processAssets.tapPromise({
|
|
71
73
|
name: pluginName,
|
|
72
74
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
73
|
-
}, (assets) => {
|
|
75
|
+
}, (assets) => __awaiter(this, void 0, void 0, function* () {
|
|
74
76
|
onStart();
|
|
75
77
|
debug('start');
|
|
76
78
|
for (const chunk of compilation.chunks) {
|
|
@@ -91,7 +93,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
91
93
|
const hash = cache.computeHash(rawSource);
|
|
92
94
|
const cacheKey = file;
|
|
93
95
|
cache.calcHashValueChanged(cacheKey, hash);
|
|
94
|
-
cache.process(cacheKey, () => {
|
|
96
|
+
yield cache.process(cacheKey, () => {
|
|
95
97
|
const source = cache.get(cacheKey);
|
|
96
98
|
if (source) {
|
|
97
99
|
compilation.updateAsset(file, source);
|
|
@@ -122,7 +124,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
122
124
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
123
125
|
const [file, originalSource] = groupedEntries.js[i];
|
|
124
126
|
const cacheKey = removeExt(file);
|
|
125
|
-
cache.process(cacheKey, () => {
|
|
127
|
+
yield cache.process(cacheKey, () => {
|
|
126
128
|
const source = cache.get(cacheKey);
|
|
127
129
|
if (source) {
|
|
128
130
|
compilation.updateAsset(file, source);
|
|
@@ -163,7 +165,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
163
165
|
const hash = cache.computeHash(rawSource);
|
|
164
166
|
const cacheKey = file;
|
|
165
167
|
cache.calcHashValueChanged(cacheKey, hash);
|
|
166
|
-
cache.process(cacheKey, () => {
|
|
168
|
+
yield cache.process(cacheKey, () => {
|
|
167
169
|
const source = cache.get(cacheKey);
|
|
168
170
|
if (source) {
|
|
169
171
|
compilation.updateAsset(file, source);
|
|
@@ -172,8 +174,8 @@ class UnifiedWebpackPluginV5 {
|
|
|
172
174
|
else {
|
|
173
175
|
return false;
|
|
174
176
|
}
|
|
175
|
-
}, () => {
|
|
176
|
-
const css = styleHandler(rawSource, {
|
|
177
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const css = yield styleHandler(rawSource, {
|
|
177
179
|
isMainChunk: mainCssChunkMatcher(file, this.appType)
|
|
178
180
|
});
|
|
179
181
|
const source = new ConcatSource(css);
|
|
@@ -185,13 +187,13 @@ class UnifiedWebpackPluginV5 {
|
|
|
185
187
|
key: cacheKey,
|
|
186
188
|
source
|
|
187
189
|
};
|
|
188
|
-
});
|
|
190
|
+
}));
|
|
189
191
|
}
|
|
190
192
|
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
191
193
|
}
|
|
192
194
|
debug('end');
|
|
193
195
|
onEnd();
|
|
194
|
-
});
|
|
196
|
+
}));
|
|
195
197
|
});
|
|
196
198
|
}
|
|
197
199
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"description": "把tailwindcss jit引擎,带给小程序开发者们! bring tailwindcss jit engine to miniprogram developers!",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
},
|
|
103
103
|
"homepage": "https://weapp-tw.icebreaker.top",
|
|
104
104
|
"devDependencies": {
|
|
105
|
-
"@babel/core": "^7.
|
|
105
|
+
"@babel/core": "^7.23.0",
|
|
106
106
|
"@icebreakers/cli": "0.1.1",
|
|
107
107
|
"@icebreakers/readme": "0.1.0",
|
|
108
108
|
"@rollup/plugin-alias": "^5.0.0",
|
|
@@ -110,40 +110,41 @@
|
|
|
110
110
|
"@rollup/plugin-json": "^6.0.0",
|
|
111
111
|
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
112
112
|
"@rollup/plugin-terser": "^0.4.3",
|
|
113
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
113
|
+
"@rollup/plugin-typescript": "^11.1.4",
|
|
114
114
|
"@tsconfig/recommended": "^1.0.3",
|
|
115
115
|
"@types/babel__generator": "^7.6.5",
|
|
116
116
|
"@types/babel__traverse": "^7.20.2",
|
|
117
|
-
"@types/debug": "^4.1.
|
|
118
|
-
"@types/diff": "^5.0.
|
|
117
|
+
"@types/debug": "^4.1.9",
|
|
118
|
+
"@types/diff": "^5.0.5",
|
|
119
119
|
"@types/fs-extra": "^11.0.2",
|
|
120
|
-
"@types/gulp": "^4.0.
|
|
121
|
-
"@types/gulp-postcss": "^8.0.
|
|
120
|
+
"@types/gulp": "^4.0.14",
|
|
121
|
+
"@types/gulp-postcss": "^8.0.4",
|
|
122
122
|
"@types/jest": "^29.5.5",
|
|
123
123
|
"@types/js-beautify": "^1.14.1",
|
|
124
124
|
"@types/klaw": "^3.0.4",
|
|
125
125
|
"@types/loader-utils": "^2.0.4",
|
|
126
|
-
"@types/lodash": "^4.14.
|
|
127
|
-
"@types/md5": "^2.3.
|
|
128
|
-
"@types/micromatch": "^4.0.
|
|
129
|
-
"@types/node": "^20.
|
|
130
|
-
"@types/semver": "^7.5.
|
|
131
|
-
"@types/vinyl": "^2.0.
|
|
132
|
-
"@types/webpack": "^5.28.
|
|
133
|
-
"@types/webpack-sources": "^3.2.
|
|
134
|
-
"@vitest/coverage-v8": "^0.34.
|
|
135
|
-
"autoprefixer": "^10.4.
|
|
126
|
+
"@types/lodash": "^4.14.199",
|
|
127
|
+
"@types/md5": "^2.3.3",
|
|
128
|
+
"@types/micromatch": "^4.0.3",
|
|
129
|
+
"@types/node": "^20.7.0",
|
|
130
|
+
"@types/semver": "^7.5.3",
|
|
131
|
+
"@types/vinyl": "^2.0.8",
|
|
132
|
+
"@types/webpack": "^5.28.3",
|
|
133
|
+
"@types/webpack-sources": "^3.2.1",
|
|
134
|
+
"@vitest/coverage-v8": "^0.34.5",
|
|
135
|
+
"autoprefixer": "^10.4.16",
|
|
136
136
|
"babel-loader": "^9.1.3",
|
|
137
137
|
"bumpp": "^9.2.0",
|
|
138
138
|
"colorette": "^2.0.20",
|
|
139
139
|
"cross-env": "^7.0.3",
|
|
140
140
|
"css-loader": "^6.8.1",
|
|
141
|
+
"css-to-tailwindcss-plugin": "^0.1.5",
|
|
141
142
|
"dedent": "^1.5.1",
|
|
142
143
|
"defu": "6.1.2",
|
|
143
144
|
"del": "^7.1.0",
|
|
144
145
|
"diff": "^5.1.0",
|
|
145
146
|
"domhandler": "^5.0.3",
|
|
146
|
-
"eslint": "8.
|
|
147
|
+
"eslint": "8.50.0",
|
|
147
148
|
"eslint-config-icebreaker": "^1.2.2",
|
|
148
149
|
"eslint-config-prettier": "^9.0.0",
|
|
149
150
|
"eslint-plugin-prettier": "^5.0.0",
|
|
@@ -165,8 +166,9 @@
|
|
|
165
166
|
"postcss-rem-to-responsive-pixel": "^5.1.3",
|
|
166
167
|
"prettier": "^3.0.3",
|
|
167
168
|
"promisify-loader-runner": "^1.0.0",
|
|
168
|
-
"rollup": "^3.29.
|
|
169
|
+
"rollup": "^3.29.3",
|
|
169
170
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
171
|
+
"sass": "^1.68.0",
|
|
170
172
|
"style-loader": "^3.3.3",
|
|
171
173
|
"tailwind-children": "^0.5.0",
|
|
172
174
|
"tailwindcss": "^3.3.3",
|
|
@@ -179,19 +181,19 @@
|
|
|
179
181
|
"typescript-transform-paths": "^3.4.6",
|
|
180
182
|
"vinyl": "^3.0.0",
|
|
181
183
|
"vite": "^4.4.9",
|
|
182
|
-
"vitest": "^0.34.
|
|
184
|
+
"vitest": "^0.34.5",
|
|
183
185
|
"weapp-tailwindcss-children": "^0.1.0",
|
|
184
186
|
"webpack": "^5.88.2",
|
|
185
187
|
"webpack-build-utils": "^0.0.4"
|
|
186
188
|
},
|
|
187
189
|
"dependencies": {
|
|
188
190
|
"@ast-core/escape": "^1.0.1",
|
|
189
|
-
"@babel/generator": "^7.
|
|
190
|
-
"@babel/parser": "^7.
|
|
191
|
-
"@babel/traverse": "^7.
|
|
192
|
-
"@babel/types": "^7.
|
|
191
|
+
"@babel/generator": "^7.23.0",
|
|
192
|
+
"@babel/parser": "^7.23.0",
|
|
193
|
+
"@babel/traverse": "^7.23.0",
|
|
194
|
+
"@babel/types": "^7.23.0",
|
|
193
195
|
"@csstools/postcss-is-pseudo-class": "^4.0.2",
|
|
194
|
-
"@tailwindcss-mangle/shared": "^2.2.
|
|
196
|
+
"@tailwindcss-mangle/shared": "^2.2.2",
|
|
195
197
|
"@weapp-core/escape": "^2.0.0",
|
|
196
198
|
"@weapp-core/regex": "^1.0.1",
|
|
197
199
|
"debug": "^4.3.4",
|
|
@@ -204,7 +206,7 @@
|
|
|
204
206
|
"postcss": "8.4.30",
|
|
205
207
|
"postcss-selector-parser": "^6.0.13",
|
|
206
208
|
"semver": "^7.5.4",
|
|
207
|
-
"tailwindcss-patch": "^2.2.
|
|
209
|
+
"tailwindcss-patch": "^2.2.2"
|
|
208
210
|
},
|
|
209
211
|
"packageManager": "pnpm@8.7.4",
|
|
210
212
|
"engines": {
|
|
@@ -247,6 +249,8 @@
|
|
|
247
249
|
"ls:pack": "npm pack --dry-run",
|
|
248
250
|
"cli:patch": "node bin/weapp-tailwindcss.js patch",
|
|
249
251
|
"release": "bumpp",
|
|
252
|
+
"css-build": "css2plugin build css-plugin.css css-plugin-scss.scss --cwd test/fixtures/css",
|
|
253
|
+
"css-build-out": "css2plugin build css-plugin.css css-plugin-scss.scss --cwd test/fixtures/css --out tw-plugins",
|
|
250
254
|
"-------": "-----------",
|
|
251
255
|
"postinstall": "node bin/weapp-tailwindcss.js patch"
|
|
252
256
|
}
|