esm-styles 0.3.6 → 0.3.7
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/lib/build.js +6 -1
- package/doc/usage-guide.md +1 -0
- package/package.json +3 -1
package/dist/lib/build.js
CHANGED
|
@@ -6,6 +6,7 @@ import path from 'node:path';
|
|
|
6
6
|
import fs from 'node:fs/promises';
|
|
7
7
|
// import { inspect } from 'node:util'
|
|
8
8
|
import _ from 'lodash';
|
|
9
|
+
import CleanCSS from 'clean-css';
|
|
9
10
|
export async function build(configPath = 'esm-styles.config.js') {
|
|
10
11
|
// --- Supporting module generation ---
|
|
11
12
|
// Debug: log mergedSets and sets
|
|
@@ -177,7 +178,7 @@ export async function build(configPath = 'esm-styles.config.js') {
|
|
|
177
178
|
// Track output files for each floor
|
|
178
179
|
const floorFiles = [];
|
|
179
180
|
for (const floor of floors) {
|
|
180
|
-
const { source, layer, outputPath: floorOutputPath } = floor;
|
|
181
|
+
const { source, layer, outputPath: floorOutputPath, minify } = floor;
|
|
181
182
|
const inputFile = path.join(sourcePath, `${source}${suffix}`);
|
|
182
183
|
// Use floor's outputPath if provided, otherwise use default
|
|
183
184
|
const floorOutputDir = floorOutputPath
|
|
@@ -201,6 +202,10 @@ export async function build(configPath = 'esm-styles.config.js') {
|
|
|
201
202
|
}
|
|
202
203
|
wrappedCss = `${comment}@layer ${layer} {\n${css}\n}`;
|
|
203
204
|
}
|
|
205
|
+
// if floor should be minified, minify wrappedCss string
|
|
206
|
+
if (minify) {
|
|
207
|
+
wrappedCss = new CleanCSS().minify(wrappedCss).styles;
|
|
208
|
+
}
|
|
204
209
|
await fs.writeFile(outputFile, wrappedCss, 'utf8');
|
|
205
210
|
// Calculate relative path from default output directory for imports
|
|
206
211
|
const relativePath = floorOutputPath
|
package/doc/usage-guide.md
CHANGED
|
@@ -351,6 +351,7 @@ floors: [
|
|
|
351
351
|
{ source: 'layout', layer: 'layout' },
|
|
352
352
|
{ source: 'utilities' }, // No layer wrapper
|
|
353
353
|
{ source: 'overrides', outputPath: 'special' }, // Custom output path
|
|
354
|
+
{ source: 'minified', minify: true }, // Minify CSS file
|
|
354
355
|
]
|
|
355
356
|
```
|
|
356
357
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esm-styles",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "A library for working with ESM styles",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"watch": "dist/watch.js"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"@types/clean-css": "^4.2.11",
|
|
38
39
|
"@types/jest": "^29.5.14",
|
|
39
40
|
"@types/js-beautify": "^1.14.3",
|
|
40
41
|
"@types/lodash": "^4.17.16",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"typescript": "^5.8.3"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
53
|
+
"clean-css": "^5.3.3",
|
|
52
54
|
"js-beautify": "^1.15.4"
|
|
53
55
|
},
|
|
54
56
|
"repository": {
|