@ecopages/lightningcss-processor 0.7.1 → 0.8.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/README.md +23 -13
- package/package.json +3 -3
- package/src/lightningcss-engine.d.ts +7 -2
- package/src/lightningcss-engine.js +15 -5
package/README.md
CHANGED
|
@@ -55,19 +55,29 @@ export default defineConfig({
|
|
|
55
55
|
|
|
56
56
|
## Options
|
|
57
57
|
|
|
58
|
-
| Option | Description
|
|
59
|
-
| :-------------- |
|
|
60
|
-
| `targets` | Browserslist queries, a string or an array. Unset, nothing is lowered.
|
|
61
|
-
| `minify` | Minify the CSS. On in production, off otherwise.
|
|
62
|
-
| `drafts` | Draft syntax, such as `{ customMedia: true }`.
|
|
63
|
-
| `nonStandard` | Non-standard syntax, such as `{ deepSelectorCombinator: true }`.
|
|
64
|
-
| `include` | Names of Lightning CSS `Features` to compile even when `targets` support them, such as `['Nesting']`.
|
|
65
|
-
| `exclude` | Names of `Features` to leave as written even when `targets` do not support them.
|
|
66
|
-
| `visitor` | A Lightning CSS visitor, run over every stylesheet.
|
|
67
|
-
| `plugins` | [Plugins](#plugins) that rewrite the source or visit the rules of every stylesheet, in order.
|
|
68
|
-
| `errorRecovery` | Drop a rule Lightning CSS cannot parse with a warning, instead of failing the stylesheet.
|
|
69
|
-
| `filter` | Regex that picks the stylesheets to process. Default `/\.css$/`.
|
|
70
|
-
| `cssModules` | `{ pattern }`: how scoped class names are built. Default `'[hash]_[local]'`.
|
|
58
|
+
| Option | Description |
|
|
59
|
+
| :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
60
|
+
| `targets` | Browserslist queries, a string or an array. Unset, the app's [browserslist config](#targets) is used, and nothing is lowered without one. `false` keeps lowering off. |
|
|
61
|
+
| `minify` | Minify the CSS. On in production, off otherwise. |
|
|
62
|
+
| `drafts` | Draft syntax, such as `{ customMedia: true }`. |
|
|
63
|
+
| `nonStandard` | Non-standard syntax, such as `{ deepSelectorCombinator: true }`. |
|
|
64
|
+
| `include` | Names of Lightning CSS `Features` to compile even when `targets` support them, such as `['Nesting']`. |
|
|
65
|
+
| `exclude` | Names of `Features` to leave as written even when `targets` do not support them. |
|
|
66
|
+
| `visitor` | A Lightning CSS visitor, run over every stylesheet. |
|
|
67
|
+
| `plugins` | [Plugins](#plugins) that rewrite the source or visit the rules of every stylesheet, in order. |
|
|
68
|
+
| `errorRecovery` | Drop a rule Lightning CSS cannot parse with a warning, instead of failing the stylesheet. |
|
|
69
|
+
| `filter` | Regex that picks the stylesheets to process. Default `/\.css$/`. |
|
|
70
|
+
| `cssModules` | `{ pattern }`: how scoped class names are built. Default `'[hash]_[local]'`. |
|
|
71
|
+
|
|
72
|
+
### Targets
|
|
73
|
+
|
|
74
|
+
The CSS is lowered for the browsers in `targets`. Where they come from, first match wins:
|
|
75
|
+
|
|
76
|
+
1. The `targets` option, when you pass one.
|
|
77
|
+
2. The app's browserslist config, found by browserslist from the app root: `.browserslistrc`, or the `browserslist` field of `package.json`.
|
|
78
|
+
3. Nothing: no lowering and no vendor prefixes.
|
|
79
|
+
|
|
80
|
+
Pass `targets: false` to keep lowering off even when the app has a config.
|
|
71
81
|
|
|
72
82
|
## Plugins
|
|
73
83
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/lightningcss-processor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Lightning CSS stylesheet processor for Ecopages: bundles @import, lowers for browser targets and minifies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lightningcss",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"directory": "packages/processors/lightningcss-processor"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@ecopages/file-system": "0.
|
|
26
|
+
"@ecopages/file-system": "0.8.0",
|
|
27
27
|
"@ecopages/logger": "^0.2.3",
|
|
28
28
|
"browserslist": "^4.28.2",
|
|
29
29
|
"lightningcss": "1.33.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@ecopages/core": "0.
|
|
32
|
+
"@ecopages/core": "0.8.0",
|
|
33
33
|
"@tailwindcss/node": ">=4",
|
|
34
34
|
"@tailwindcss/oxide": ">=4",
|
|
35
35
|
"tailwindcss": ">=4"
|
|
@@ -28,9 +28,14 @@ export interface LightningCssPlugin {
|
|
|
28
28
|
/** The options of the Lightning CSS Processor. */
|
|
29
29
|
export interface LightningCssOptions {
|
|
30
30
|
/**
|
|
31
|
-
* Browserslist queries to lower the CSS for, such as `['chrome >= 90', 'safari >= 15']`.
|
|
31
|
+
* Browserslist queries to lower the CSS for, such as `['chrome >= 90', 'safari >= 15']`.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Unset, the queries come from the app's browserslist config (`.browserslistrc` or the `browserslist` field of
|
|
35
|
+
* `package.json`, found by browserslist's own lookup from the app root), and nothing is lowered when there is none.
|
|
36
|
+
* `false` keeps lowering off even when a config exists.
|
|
32
37
|
*/
|
|
33
|
-
targets?: string | readonly string[];
|
|
38
|
+
targets?: string | readonly string[] | false;
|
|
34
39
|
/**
|
|
35
40
|
* Whether to minify the CSS.
|
|
36
41
|
* @default true in production, false otherwise
|
|
@@ -24,12 +24,22 @@ export function loadLightningCss() {
|
|
|
24
24
|
});
|
|
25
25
|
return engine;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The Lightning CSS `targets` for the `targets` option, or `undefined` to lower nothing.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* An explicit option, including an empty one, wins over the config; only an unset option reads the browserslist
|
|
32
|
+
* config of the app at `rootDir`. No default browser set is invented, since Tailwind v4 apps already target modern
|
|
33
|
+
* browsers.
|
|
34
|
+
*/
|
|
35
|
+
async function resolveTargets(queries, rootDir) {
|
|
36
|
+
if (queries === false)
|
|
37
|
+
return undefined;
|
|
38
|
+
const configured = queries ?? browserslist.loadConfig({ path: rootDir });
|
|
39
|
+
if (!configured || configured.length === 0)
|
|
30
40
|
return undefined;
|
|
31
41
|
const { browserslistToTargets } = await loadLightningCss();
|
|
32
|
-
return browserslistToTargets(browserslist(typeof
|
|
42
|
+
return browserslistToTargets(browserslist(typeof configured === 'string' ? configured : [...configured]));
|
|
33
43
|
}
|
|
34
44
|
/** Combines feature names into the bit flags Lightning CSS takes. */
|
|
35
45
|
async function toFeatureFlags(names) {
|
|
@@ -65,7 +75,7 @@ export async function resolveLightningCssOptions(options, rootDir) {
|
|
|
65
75
|
nonStandard: options?.nonStandard,
|
|
66
76
|
visitor: options?.visitor,
|
|
67
77
|
errorRecovery: options?.errorRecovery,
|
|
68
|
-
targets: await resolveTargets(options?.targets),
|
|
78
|
+
targets: await resolveTargets(options?.targets, rootDir),
|
|
69
79
|
include: await toFeatureFlags(options?.include),
|
|
70
80
|
exclude: await toFeatureFlags(options?.exclude),
|
|
71
81
|
}),
|