@plumeria/webpack-plugin 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -17
- package/dist/virtual-css-loader.js +6 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PlumeriaPlugin = void 0;
|
|
7
|
-
const webpack_1 = require("webpack");
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
9
8
|
const fs_1 = __importDefault(require("fs"));
|
|
10
9
|
const PLUGIN_NAME = 'PlumeriaPlugin';
|
|
@@ -29,14 +28,6 @@ class PlumeriaPlugin {
|
|
|
29
28
|
}
|
|
30
29
|
});
|
|
31
30
|
});
|
|
32
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
33
|
-
compilation.hooks.processAssets.tap({
|
|
34
|
-
name: PLUGIN_NAME,
|
|
35
|
-
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
36
|
-
}, () => {
|
|
37
|
-
this.writeCSS();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
31
|
}
|
|
41
32
|
registerFileStyles(filePath, styles) {
|
|
42
33
|
const prev = this.stylesByFile.get(filePath) || {
|
|
@@ -52,14 +43,14 @@ class PlumeriaPlugin {
|
|
|
52
43
|
}
|
|
53
44
|
generateOrderedCSS() {
|
|
54
45
|
const allStyles = Array.from(this.stylesByFile.values());
|
|
55
|
-
const
|
|
46
|
+
const globalStylesSet = new Set();
|
|
56
47
|
const keyframeStylesSet = new Set();
|
|
57
48
|
const varStylesSet = new Set();
|
|
58
49
|
const themeStylesSet = new Set();
|
|
59
|
-
const
|
|
50
|
+
const baseStylesSet = new Set();
|
|
60
51
|
for (const s of allStyles) {
|
|
61
52
|
if (s.globalStyles)
|
|
62
|
-
|
|
53
|
+
globalStylesSet.add(s.globalStyles);
|
|
63
54
|
if (s.keyframeStyles)
|
|
64
55
|
keyframeStylesSet.add(s.keyframeStyles);
|
|
65
56
|
if (s.varStyles)
|
|
@@ -67,22 +58,24 @@ class PlumeriaPlugin {
|
|
|
67
58
|
if (s.themeStyles)
|
|
68
59
|
themeStylesSet.add(s.themeStyles);
|
|
69
60
|
if (s.baseStyles)
|
|
70
|
-
|
|
61
|
+
baseStylesSet.add(s.baseStyles);
|
|
71
62
|
}
|
|
72
63
|
return [
|
|
73
|
-
...
|
|
64
|
+
...Array.from(globalStylesSet),
|
|
74
65
|
...Array.from(keyframeStylesSet),
|
|
75
66
|
...Array.from(varStylesSet),
|
|
76
67
|
...Array.from(themeStylesSet),
|
|
77
|
-
...
|
|
68
|
+
...Array.from(baseStylesSet),
|
|
78
69
|
]
|
|
79
70
|
.filter(Boolean)
|
|
80
71
|
.join('\n');
|
|
81
72
|
}
|
|
82
73
|
writeCSS() {
|
|
83
74
|
const css = this.generateOrderedCSS();
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
if (css.trim().length > 0) {
|
|
76
|
+
fs_1.default.mkdirSync(path_1.default.dirname(this.outFile), { recursive: true });
|
|
77
|
+
fs_1.default.writeFileSync(this.outFile, css, 'utf-8');
|
|
78
|
+
}
|
|
86
79
|
}
|
|
87
80
|
}
|
|
88
81
|
exports.PlumeriaPlugin = PlumeriaPlugin;
|
|
@@ -543,6 +543,10 @@ function isCSSDefineFile(filePath, target) {
|
|
|
543
543
|
function loader(source) {
|
|
544
544
|
const callback = this.async();
|
|
545
545
|
this.addDependency(this.resourcePath);
|
|
546
|
+
const files = (0, glob_1.globSync)(PATTERN_PATH, GLOB_OPTIONS);
|
|
547
|
+
for (const file of files) {
|
|
548
|
+
this.addDependency(file);
|
|
549
|
+
}
|
|
546
550
|
constTable = scanForDefineConsts.call(this);
|
|
547
551
|
const { keyframesHashTableLocal, keyframesObjectTableLocal } = scanForKeyframes.call(this);
|
|
548
552
|
keyframesHashTable = keyframesHashTableLocal;
|
|
@@ -629,7 +633,8 @@ function loader(source) {
|
|
|
629
633
|
.styleSheet)
|
|
630
634
|
.join('\n');
|
|
631
635
|
}
|
|
632
|
-
const
|
|
636
|
+
const VIRTUAL_FILE_PATH = path_1.default.resolve(__dirname, '..', 'zero-virtual.css');
|
|
637
|
+
const VIRTUAL_CSS_PATH = require.resolve(VIRTUAL_FILE_PATH);
|
|
633
638
|
function stringifyRequest(loaderContext, request) {
|
|
634
639
|
return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
|
|
635
640
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/webpack-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Plumeria Webpack plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,11 +23,14 @@
|
|
|
23
23
|
"@babel/core": "^7.28.0",
|
|
24
24
|
"@babel/preset-react": "^7.27.1",
|
|
25
25
|
"@babel/preset-typescript": "^7.27.1",
|
|
26
|
-
"@babel/types": "^7.28.2"
|
|
26
|
+
"@babel/types": "^7.28.2",
|
|
27
|
+
"loader-utils": "^3.3.1",
|
|
28
|
+
"webpack-virtual-modules": "^0.6.2"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
31
|
"@rust-gear/glob": "^0.2.2",
|
|
30
32
|
"@types/babel__core": "^7.20.5",
|
|
33
|
+
"@types/loader-utils": "^2.0.6",
|
|
31
34
|
"webpack": "^5.101.0",
|
|
32
35
|
"zss-engine": "^0.2.75"
|
|
33
36
|
},
|