@gouvfr/dsfr-alchemist 2.0.0-alpha.3.1 → 2.0.0-alpha.4.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gouvfr/dsfr-alchemist",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.4.0",
|
|
4
4
|
"description": "Le module `dsfr-alchemist` est un outil permettant de compiler les feuilles de style et les scripts du DSFR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Système de Design de l'État",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
],
|
|
71
71
|
"main": "./index.js",
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@gouvfr/dsfr-forge": "=2.0.0-alpha.
|
|
73
|
+
"@gouvfr/dsfr-forge": "=2.0.0-alpha.4.0",
|
|
74
74
|
"esbuild": "^0.27.2",
|
|
75
|
-
"lightningcss": "^1.
|
|
75
|
+
"lightningcss": "^1.33.0",
|
|
76
76
|
"sass": "^1.98.0"
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -4,6 +4,14 @@ import * as url from 'node:url';
|
|
|
4
4
|
import { createFile, log, format } from '@gouvfr/dsfr-forge';
|
|
5
5
|
import { transform } from 'lightningcss';
|
|
6
6
|
|
|
7
|
+
const MASKS = [
|
|
8
|
+
{
|
|
9
|
+
pattern: /@container\s+anchored\s*\(/g,
|
|
10
|
+
placeholder: '@x-anchored-container (',
|
|
11
|
+
restore: '@container anchored ('
|
|
12
|
+
}
|
|
13
|
+
];
|
|
14
|
+
|
|
7
15
|
class StyleCompiler {
|
|
8
16
|
_getDestFile (dest, filename, minify = false, sourceMap = false) {
|
|
9
17
|
const appendices = ['css'];
|
|
@@ -66,10 +74,25 @@ class StyleCompiler {
|
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
|
|
77
|
+
|
|
78
|
+
mask (str) {
|
|
79
|
+
MASKS.forEach(({ pattern, placeholder }) => {
|
|
80
|
+
str = str.replace(pattern, placeholder);
|
|
81
|
+
});
|
|
82
|
+
return str;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
unmask (str) {
|
|
86
|
+
MASKS.forEach(({ placeholder, restore }) => {
|
|
87
|
+
str = str.replace(placeholder, restore);
|
|
88
|
+
});
|
|
89
|
+
return str;
|
|
90
|
+
}
|
|
91
|
+
|
|
69
92
|
async _minify (dest, filename, minify, sourceMap, css) {
|
|
70
93
|
const options = {
|
|
71
94
|
filename: filename,
|
|
72
|
-
code: Buffer.from(css),
|
|
95
|
+
code: Buffer.from(this.mask(css)),
|
|
73
96
|
minify: true
|
|
74
97
|
};
|
|
75
98
|
|
|
@@ -80,6 +103,8 @@ class StyleCompiler {
|
|
|
80
103
|
|
|
81
104
|
let { code, map } = transform(options);
|
|
82
105
|
|
|
106
|
+
code = this.unmask(code.toString());
|
|
107
|
+
|
|
83
108
|
await this._create(dest, filename, minify, map, code);
|
|
84
109
|
}
|
|
85
110
|
|