@hiscovega/grisso 1.0.2 → 1.0.4
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 +125 -7
- package/dist/grisso.css +1 -1
- package/lib/build.d.ts +23 -0
- package/lib/build.js +29 -0
- package/lib/generators.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/optimize.d.ts +14 -0
- package/lib/optimize.js +88 -0
- package/lib/partials/flex-and-grid.js +1 -1
- package/lib/partials/index.js +5 -5
- package/lib/partials/layout.js +1 -1
- package/lib/partials/sizing.js +1 -1
- package/lib/partials/typography.js +1 -1
- package/lib/purge.d.ts +12 -0
- package/lib/purge.js +39 -0
- package/lib/utils.js +1 -1
- package/package.json +20 -11
- package/plugin.js +8 -42
- package/tokens-example.css +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
## Instalación
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @hiscovega/grisso
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Uso
|
|
@@ -16,13 +16,13 @@ Importa el CSS pre-compilado directamente. Útil para desarrollo o cuando no usa
|
|
|
16
16
|
|
|
17
17
|
```css
|
|
18
18
|
/* En tu CSS global */
|
|
19
|
-
@import "@
|
|
19
|
+
@import "@hiscovega/grisso";
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
O en HTML:
|
|
23
23
|
|
|
24
24
|
```html
|
|
25
|
-
<link rel="stylesheet" href="node_modules/@
|
|
25
|
+
<link rel="stylesheet" href="node_modules/@hiscovega/grisso/dist/grisso.css" />
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
### Opción B: PostCSS plugin (recomendado — con tree-shaking)
|
|
@@ -31,7 +31,7 @@ Añade el plugin a tu configuración de PostCSS. El CSS de Grisso se inyecta aut
|
|
|
31
31
|
|
|
32
32
|
```js
|
|
33
33
|
// postcss.config.js
|
|
34
|
-
import grisso from "@
|
|
34
|
+
import grisso from "@hiscovega/grisso/plugin";
|
|
35
35
|
|
|
36
36
|
export default {
|
|
37
37
|
plugins: [
|
|
@@ -48,6 +48,104 @@ Sin `content`, se incluye todo el CSS (útil en desarrollo):
|
|
|
48
48
|
grisso();
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
### Opción C: API programática (sin PostCSS)
|
|
52
|
+
|
|
53
|
+
Usa `buildCSS()` directamente desde Node.js. Genera, purga y optimiza CSS sin depender de PostCSS — ideal para scripts de build, herramientas custom o entornos donde PostCSS no está disponible.
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { buildCSS } from "@hiscovega/grisso/build";
|
|
57
|
+
|
|
58
|
+
// Build completo (todo el CSS, minificado)
|
|
59
|
+
const css = await buildCSS();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Opciones de `buildCSS()`:**
|
|
63
|
+
|
|
64
|
+
| Opción | Tipo | Default | Descripción |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| `config` | `string` | — | Ruta a `grisso.config.mjs` personalizado |
|
|
67
|
+
| `content` | `string[]` | — | Globs de archivos a escanear para tree-shaking |
|
|
68
|
+
| `minify` | `boolean` | `true` | Minificar el CSS de salida |
|
|
69
|
+
|
|
70
|
+
Sin `content`, se incluye todo el CSS. Con `content`, se eliminan las clases no usadas via PurgeCSS.
|
|
71
|
+
|
|
72
|
+
#### Ejemplos
|
|
73
|
+
|
|
74
|
+
**Tree-shaking** — solo las clases que usa tu proyecto:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
const css = await buildCSS({
|
|
78
|
+
content: ["./src/**/*.{js,ts,jsx,tsx}", "./src/**/*.css"],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Config personalizada + tree-shaking:**
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
const css = await buildCSS({
|
|
86
|
+
config: "./grisso.config.mjs",
|
|
87
|
+
content: ["./src/**/*.{js,ts,jsx,tsx,css}"],
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**CSS sin minificar** (útil para depuración):
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
const css = await buildCSS({ minify: false });
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Script de build** — genera un archivo CSS para producción:
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
// scripts/build-css.mjs
|
|
101
|
+
import { writeFileSync } from "node:fs";
|
|
102
|
+
import { buildCSS } from "@hiscovega/grisso/build";
|
|
103
|
+
|
|
104
|
+
const css = await buildCSS({
|
|
105
|
+
content: ["./src/**/*.{jsx,tsx,css}"],
|
|
106
|
+
config: "./grisso.config.mjs",
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
writeFileSync("./dist/styles.css", css);
|
|
110
|
+
console.log(`CSS generado: ${css.length} bytes`);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Integración con Vite** (plugin custom):
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
// vite.config.js
|
|
117
|
+
import { buildCSS } from "@hiscovega/grisso/build";
|
|
118
|
+
|
|
119
|
+
export default {
|
|
120
|
+
plugins: [
|
|
121
|
+
{
|
|
122
|
+
name: "grisso",
|
|
123
|
+
async buildStart() {
|
|
124
|
+
const css = await buildCSS({
|
|
125
|
+
content: ["./src/**/*.{jsx,tsx,css}"],
|
|
126
|
+
});
|
|
127
|
+
this.emitFile({ type: "asset", fileName: "grisso.css", source: css });
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
};
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Servidor de desarrollo** — generar CSS on-the-fly:
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
// Ejemplo con Express
|
|
138
|
+
import express from "express";
|
|
139
|
+
import { buildCSS } from "@hiscovega/grisso/build";
|
|
140
|
+
|
|
141
|
+
const app = express();
|
|
142
|
+
|
|
143
|
+
app.get("/grisso.css", async (req, res) => {
|
|
144
|
+
const css = await buildCSS({ minify: false });
|
|
145
|
+
res.type("text/css").send(css);
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
51
149
|
## Configuración personalizada
|
|
52
150
|
|
|
53
151
|
Crea un `grisso.config.mjs` en la raíz de tu proyecto para extender o reemplazar los tokens por defecto. Sigue el patrón de Tailwind v3:
|
|
@@ -85,14 +183,14 @@ grisso({
|
|
|
85
183
|
|
|
86
184
|
Si no se pasa `config`, el plugin busca automáticamente `grisso.config.mjs` en el directorio de trabajo. Si no existe, usa los defaults.
|
|
87
185
|
|
|
88
|
-
Los defaults se pueden consultar importando `@
|
|
186
|
+
Los defaults se pueden consultar importando `@hiscovega/grisso/config`.
|
|
89
187
|
|
|
90
188
|
## Design Tokens (CSS custom properties)
|
|
91
189
|
|
|
92
190
|
Grisso usa CSS custom properties para todos los valores. Copia `tokens-example.css` y adapta los valores a tu design system:
|
|
93
191
|
|
|
94
192
|
```bash
|
|
95
|
-
cp node_modules/@
|
|
193
|
+
cp node_modules/@hiscovega/grisso/tokens-example.css src/tokens.css
|
|
96
194
|
```
|
|
97
195
|
|
|
98
196
|
```css
|
|
@@ -110,7 +208,7 @@ Importa los tokens antes que Grisso en tu CSS global:
|
|
|
110
208
|
|
|
111
209
|
```css
|
|
112
210
|
@import "./tokens.css";
|
|
113
|
-
@import "@
|
|
211
|
+
@import "@hiscovega/grisso"; /* o via plugin de PostCSS */
|
|
114
212
|
```
|
|
115
213
|
|
|
116
214
|
## Clases disponibles
|
|
@@ -152,6 +250,8 @@ Ejemplos: `flex`, `tablet-flex`, `p-md`, `desktop-mt-lg`, `text-center`
|
|
|
152
250
|
npm run build # Compila TS + genera dist/grisso.css (~156 KB)
|
|
153
251
|
npm run typecheck # Type-check sin emitir (tsc --noEmit)
|
|
154
252
|
npm run lint # Lint con Biome
|
|
253
|
+
npm test # Tests con Vitest
|
|
254
|
+
npm run test:watch # Tests en modo watch
|
|
155
255
|
npm run playground # Build + tree-shake + abre playground/index.html
|
|
156
256
|
```
|
|
157
257
|
|
|
@@ -185,6 +285,24 @@ simpleClass("flex", "display", "flex", breakpoints);
|
|
|
185
285
|
complexClass("p-", "padding", spacing, breakpoints);
|
|
186
286
|
```
|
|
187
287
|
|
|
288
|
+
## Publicación (release)
|
|
289
|
+
|
|
290
|
+
El proyecto usa [release-it](https://github.com/release-it/release-it) para gestionar versiones y publicación a npm. Antes de publicar se ejecutan automáticamente lint, tests y build.
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
npm run release # Bump interactivo (patch/minor/major)
|
|
294
|
+
npm run release -- patch # Bump patch directo
|
|
295
|
+
npm run release -- minor # Bump minor directo
|
|
296
|
+
npm run release -- major # Bump major directo
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
El flujo de release:
|
|
300
|
+
|
|
301
|
+
1. Ejecuta `npm run lint`, `npm test` y `npm run build`
|
|
302
|
+
2. Bump de versión en `package.json`
|
|
303
|
+
3. Commit `chore: release v{version}` + tag `v{version}`
|
|
304
|
+
4. Publica a npm
|
|
305
|
+
|
|
188
306
|
## grisso-reduce (tree-shaking alternativo)
|
|
189
307
|
|
|
190
308
|
`grisso-reduce/index.ts` es una herramienta alternativa de tree-shaking que escanea declaraciones `composes: ... from global` en archivos CSS y elimina clases no usadas del output.
|