@massimo-cassandro/minimo 1.16.0 → 1.16.2
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 +12 -3
- package/design-tokens/_src/typography.minimo.tokens.mjs +1 -1
- package/dev-tools/README.md +11 -7
- package/dev-tools/starter-kit/TODO.md +135 -0
- package/dev-tools/{webpack-setup/merge-jsonc.cjs → starter-kit/src/merge-jsonc.mjs} +40 -15
- package/dev-tools/{webpack-setup → starter-kit}/starter-install.sh +22 -3
- package/dev-tools/starter-kit/templates/_root_htaccess +68 -0
- package/dev-tools/starter-kit/templates/_root_robots.txt +5 -0
- package/dev-tools/starter-kit/templates/entry-tpl.critical.css +18 -0
- package/dev-tools/starter-kit/templates/entry-tpl.css +24 -0
- package/dev-tools/starter-kit/templates/tokens-config.mjs +33 -0
- package/dev-tools/{webpack-setup → starter-kit}/webpack-modules/css-rules.mjs +6 -1
- package/dev-tools/{webpack-setup → starter-kit}/webpack-modules/postcss.config.mjs +14 -34
- package/dev-tools/starter-kit/webpack-modules/purgecss-variables-safelist.mjs +92 -0
- package/dev-tools/{webpack-setup → starter-kit}/webpack.config.mjs +169 -59
- package/package.json +4 -2
- package/src/css/dimensions.css +3 -0
- package/src/css/margin-padding-bootstrap-media.css +1844 -0
- package/src/css/margin-padding-bootstrap.css +464 -0
- package/src/css/margin-padding-media.css +1843 -0
- package/src/css/margin-padding.css +405 -45
- package/src/custom-media.css +12 -0
- package/src/minimo.css +5 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/__project__.code-workspace +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/_browserslistrc +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/_editorconfig +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/_gitignore +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/_prettierrc +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/eslint.config.mjs +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/jsconfig.json +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/package-tpl.json +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/templates/stylelint.config.mjs +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/webpack-modules/get-jsConfig-aliases.mjs +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/webpack-modules/mini-svg-data-uri-loader.cjs +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/webpack-modules/svg-rules.mjs +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/webpack-modules/svgo.config.mjs +0 -0
- /package/dev-tools/{webpack-setup → starter-kit}/webpack-template.ejs +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// webpack-modules/purgecss-variables-safelist.mjs
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { globSync } from 'glob';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Genera l'elenco di custom properties da passare a `safelist.variables` di PurgeCSS.
|
|
7
|
+
L'elenco viene ricalcolato in memoria a ogni avvio di webpack: nessun file su disco.
|
|
8
|
+
|
|
9
|
+
Perché serve: PurgeCSS (`variables: true`) registra l'uso delle variabili solo
|
|
10
|
+
nelle regole che effettivamente elabora, all'interno del singolo asset css.
|
|
11
|
+
Restano quindi "invisibili" gli usi di var() che avvengono:
|
|
12
|
+
|
|
13
|
+
1. nei blocchi racchiusi tra i commenti `purgecss start/end ignore`
|
|
14
|
+
(presenti ad es. nei sorgenti di minimo): le regole vengono mantenute,
|
|
15
|
+
ma le custom properties che consumano verrebbero rimosse dal :root;
|
|
16
|
+
2. nei css caricati fuori dagli asset purgati (shadow DOM dei web components,
|
|
17
|
+
import con `?raw`): consumano le props del :root della pagina;
|
|
18
|
+
3. nelle dichiarazioni di un asset consumate in un altro asset
|
|
19
|
+
(es. override di tema definiti nel css di una pagina e consumati
|
|
20
|
+
dal css globale): vanno indicate tramite `seeds`.
|
|
21
|
+
|
|
22
|
+
Inoltre `safelist.variables` NON segue le catene di dipendenze (una prop
|
|
23
|
+
safelisted resta nel css, ma i suoi riferimenti var() non vengono marcati
|
|
24
|
+
come usati: `--a: var(--b)` in safelist non salva `--b`): l'elenco viene
|
|
25
|
+
quindi espanso con la chiusura transitiva calcolata sul grafo di tutte le
|
|
26
|
+
dichiarazioni `--x: ...` presenti nei sorgenti.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const VAR_REFS_REGEX = /var\(\s*(--[A-Za-z0-9_-]+)/g;
|
|
30
|
+
const DECLARATION_REGEX = /(--[A-Za-z0-9_-]+)\s*:\s*([^;}]+)/g;
|
|
31
|
+
const IGNORE_START_REGEX = /\/\*\s*purgecss start ignore\s*\*\//;
|
|
32
|
+
const IGNORE_END_REGEX = /\/\*\s*purgecss end ignore\s*\*\//;
|
|
33
|
+
|
|
34
|
+
const varRefs = (cssText) => [...cssText.matchAll(VAR_REFS_REGEX)].map(m => m[1]);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {object} params
|
|
38
|
+
* @param {string[]} params.declarationGlobs glob dei css che contribuiscono al grafo
|
|
39
|
+
* delle dipendenze; i loro blocchi `purgecss ignore` contano come usi
|
|
40
|
+
* @param {string[]} [params.shadowGlobs] glob dei css usati fuori dagli asset purgati
|
|
41
|
+
* (shadow DOM / `?raw`): TUTTI i loro usi di var() contano
|
|
42
|
+
* @param {(string|RegExp)[]} [params.seeds] props da mantenere comunque (nomi o pattern
|
|
43
|
+
* risolti sui nomi dichiarati), es. override consumati in un altro asset
|
|
44
|
+
* @returns {string[]} elenco ordinato di nomi di custom properties
|
|
45
|
+
*/
|
|
46
|
+
export function purgecssVariablesSafelist({ declarationGlobs, shadowGlobs = [], seeds = [] }) {
|
|
47
|
+
|
|
48
|
+
const declaredRefs = new Map(); // nome → Set(var() referenziate nelle sue dichiarazioni)
|
|
49
|
+
const usages = new Set(); // usi da mantenere (blocchi ignore + shadow css)
|
|
50
|
+
|
|
51
|
+
for (const file of globSync(declarationGlobs, { nodir: true })) {
|
|
52
|
+
const src = fs.readFileSync(file, 'utf8');
|
|
53
|
+
|
|
54
|
+
// grafo delle dipendenze: ogni dichiarazione `--x: ...` con le var() nel valore
|
|
55
|
+
for (const declaration of src.matchAll(DECLARATION_REGEX)) {
|
|
56
|
+
const [, name, value] = declaration;
|
|
57
|
+
if (!declaredRefs.has(name)) {
|
|
58
|
+
declaredRefs.set(name, new Set());
|
|
59
|
+
}
|
|
60
|
+
varRefs(value).forEach(ref => declaredRefs.get(name).add(ref));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// usi di var() nei blocchi `purgecss start/end ignore`
|
|
64
|
+
src.split(IGNORE_START_REGEX).slice(1).forEach(chunk => {
|
|
65
|
+
varRefs(chunk.split(IGNORE_END_REGEX)[0]).forEach(ref => usages.add(ref));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// shadow css: ogni uso di var() conta
|
|
70
|
+
for (const file of globSync(shadowGlobs, { nodir: true })) {
|
|
71
|
+
varRefs(fs.readFileSync(file, 'utf8')).forEach(ref => usages.add(ref));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// risoluzione dei seeds sui nomi dichiarati
|
|
75
|
+
const declaredNames = [...declaredRefs.keys()];
|
|
76
|
+
const seedNames = seeds.flatMap(seed =>
|
|
77
|
+
typeof seed === 'string' ? [seed] : declaredNames.filter(name => seed.test(name))
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// chiusura transitiva delle dipendenze
|
|
81
|
+
const result = new Set();
|
|
82
|
+
const queue = [...seedNames, ...usages];
|
|
83
|
+
while (queue.length > 0) {
|
|
84
|
+
const name = queue.pop();
|
|
85
|
+
if (!result.has(name)) {
|
|
86
|
+
result.add(name);
|
|
87
|
+
queue.push(...(declaredRefs.get(name) ?? []));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return [...result].sort();
|
|
92
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// webpack.config.mjs
|
|
1
|
+
// webpack.config.mjs __project_name__
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import webpack from 'webpack';
|
|
@@ -22,6 +22,7 @@ import { PurgeCSSPlugin } from 'purgecss-webpack-plugin';
|
|
|
22
22
|
import { globSync } from 'glob';
|
|
23
23
|
|
|
24
24
|
import { cssRules } from './webpack-modules/css-rules.mjs';
|
|
25
|
+
import { purgecssVariablesSafelist } from './webpack-modules/purgecss-variables-safelist.mjs';
|
|
25
26
|
import { getJsConfigAliases } from './webpack-modules/get-jsConfig-aliases.mjs';
|
|
26
27
|
import { svgRules } from './webpack-modules/svg-rules.mjs';
|
|
27
28
|
|
|
@@ -41,6 +42,7 @@ const isDevelopment = process.env.NODE_ENV === 'development'
|
|
|
41
42
|
,favicons_path_regexp = new RegExp(favicons_path) // source pattern per le favicons (regexp o null)
|
|
42
43
|
,jsConfigAliases = getJsConfigAliases(path.resolve(__dirname, './jsconfig.json'))
|
|
43
44
|
,packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, './package.json'), 'utf-8'))
|
|
45
|
+
,purgeCSSDebug = false // true per loggare i selettori rimossi da PurgeCSS a fine build
|
|
44
46
|
// ,manifest_shared_seed = {}
|
|
45
47
|
;
|
|
46
48
|
|
|
@@ -87,6 +89,111 @@ const CopyWebpackPluginPatterns = [
|
|
|
87
89
|
// }
|
|
88
90
|
];
|
|
89
91
|
|
|
92
|
+
// =>> PurgeCSS: opzioni e istanze (usate nei plugins e dal log di debug)
|
|
93
|
+
//
|
|
94
|
+
// Vengono create DUE istanze, attive in ENTRAMBE le modalità (dev e prod),
|
|
95
|
+
// così i problemi di purge emergono subito durante lo sviluppo:
|
|
96
|
+
// - `purgeCSSPluginCritical`: solo le entry `*.critical` (purge stretto, gli asset
|
|
97
|
+
// devono essere autosufficienti e minimi perché inlinati nei template html)
|
|
98
|
+
// - `purgeCSSPlugin`: tutti gli asset (il doppio passaggio sui critical è idempotente)
|
|
99
|
+
//
|
|
100
|
+
// NB (watch mode): i template twig NON sono osservati da webpack: dopo aver
|
|
101
|
+
// aggiunto una classe solo in un twig occorre rilanciare la build (o toccare
|
|
102
|
+
// un file js/css) perché il purge venga ricalcolato.
|
|
103
|
+
// NB (dev): il plugin agisce solo sugli asset css emessi; con
|
|
104
|
+
// `inlineCssInDevMode: true` i css non-critical in dev sono iniettati da
|
|
105
|
+
// style-loader e non vengono purgati (i critical passano comunque da
|
|
106
|
+
// MiniCssExtract e sono sempre purgati)
|
|
107
|
+
|
|
108
|
+
// `paths`: SOLO file che generano markup o classi (html/ejs, twig, php, js);
|
|
109
|
+
// NIENTE file css tra i paths: verrebbero letti come "contenuto" e ogni selettore
|
|
110
|
+
// risulterebbe usato, vanificando il purge
|
|
111
|
+
const purgeCSSCommonOptions = {
|
|
112
|
+
paths: () => globSync(
|
|
113
|
+
[
|
|
114
|
+
path.resolve(__dirname, './src/**/*.{js,mjs,jsx}'),
|
|
115
|
+
path.resolve(__dirname, './*.ejs'), // template html di webpack
|
|
116
|
+
path.resolve(__dirname, './src/**/*.ejs'),
|
|
117
|
+
// progetti symfony: template twig e classi generate lato php
|
|
118
|
+
// path.resolve(__dirname, '../templates/**/*.twig'),
|
|
119
|
+
// path.resolve(__dirname, '../src/**/*.php'),
|
|
120
|
+
// il js di minimo genera markup con classi proprie (snackbar, unsplash-page, ecc.)
|
|
121
|
+
// NB: adattare il percorso di node_modules se questo config è in una
|
|
122
|
+
// sottodirectory del progetto (es. frontend/ → '../node_modules/...')
|
|
123
|
+
path.resolve(__dirname, './node_modules/@massimo-cassandro/minimo/src/**/*.{js,mjs}'),
|
|
124
|
+
],
|
|
125
|
+
{ nodir: true }
|
|
126
|
+
),
|
|
127
|
+
|
|
128
|
+
// extractor di default (/[A-Za-z0-9_-]+/g): adeguato a classi/tag/id,
|
|
129
|
+
// NON definire extractors custom (il vecchio /[A-z0-9-:/]+/ era buggato:
|
|
130
|
+
// il range [A-z] include caratteri non voluti come `[`, `\`, `^`, ...)
|
|
131
|
+
|
|
132
|
+
variables: true, // rimuove le custom properties non usate (sostituisce postcss-jit-props)
|
|
133
|
+
keyframes: true, // rimuove i @keyframes non referenziati
|
|
134
|
+
// fontFace resta false (default): i font sono referenziati solo tramite
|
|
135
|
+
// var(--font-family) e purgecss non risolve le custom properties nei valori,
|
|
136
|
+
// quindi con `true` i @font-face verrebbero rimossi anche se usati
|
|
137
|
+
|
|
138
|
+
rejected: purgeCSSDebug // popola purgedStats per il log di debug
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// safelist base minima, comune alle due istanze
|
|
142
|
+
const purgeCSSSafelistBase = {
|
|
143
|
+
standard: [
|
|
144
|
+
// classi costruite dinamicamente nei template o lato server, invisibili
|
|
145
|
+
// all'analisi statica dei paths. Esempio (da adattare al progetto):
|
|
146
|
+
// flash messages twig con class="alert alert-{{ label }}"
|
|
147
|
+
/^alert-(success|notice|error|warning)$/
|
|
148
|
+
],
|
|
149
|
+
deep: [
|
|
150
|
+
// css modules: prefisso `m_` presente in dev e prod (vedi css-rules.mjs),
|
|
151
|
+
// le classi hashate non possono comparire nei file scansionati
|
|
152
|
+
/^m_/
|
|
153
|
+
],
|
|
154
|
+
greedy: [
|
|
155
|
+
// INDISPENSABILE: purgecss non riconosce il nesting selector nativo e senza
|
|
156
|
+
// questo pattern i selettori annidati composti solo da `&` + pseudo classi
|
|
157
|
+
// (&:hover, &:focus-visible, `&` semplice, ecc.) verrebbero SEMPRE rimossi
|
|
158
|
+
/^&$/
|
|
159
|
+
]
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// css della pagina critici (inlinati nei template): purge stretto,
|
|
163
|
+
// devono essere autosufficienti e minimi
|
|
164
|
+
const purgeCSSPluginCritical = new PurgeCSSPlugin({
|
|
165
|
+
...purgeCSSCommonOptions,
|
|
166
|
+
only: ['.critical'],
|
|
167
|
+
safelist: purgeCSSSafelistBase
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// tutti gli altri asset (il purge è idempotente: il secondo passaggio
|
|
171
|
+
// sui critical non rimuove altro)
|
|
172
|
+
const purgeCSSPlugin = new PurgeCSSPlugin({
|
|
173
|
+
...purgeCSSCommonOptions,
|
|
174
|
+
safelist: {
|
|
175
|
+
...purgeCSSSafelistBase,
|
|
176
|
+
// elenco generato: usi di var() nei blocchi `purgecss ignore` e nei css
|
|
177
|
+
// shadow-DOM/`?raw`, override cross-asset (seeds), con chiusura transitiva
|
|
178
|
+
// delle dipendenze (vedi webpack-modules/purgecss-variables-safelist.mjs)
|
|
179
|
+
variables: purgecssVariablesSafelist({
|
|
180
|
+
declarationGlobs: [
|
|
181
|
+
path.resolve(__dirname, './src/**/*.css'),
|
|
182
|
+
path.resolve(__dirname, './node_modules/@massimo-cassandro/minimo/src/**/*.css'),
|
|
183
|
+
],
|
|
184
|
+
shadowGlobs: [
|
|
185
|
+
path.resolve(__dirname, './src/web-components/**/*.css'),
|
|
186
|
+
path.resolve(__dirname, './node_modules/@massimo-cassandro/minimo/src/web-components/**/*.css'),
|
|
187
|
+
],
|
|
188
|
+
seeds: [
|
|
189
|
+
// props dichiarate in un asset ma consumate in un altro (es. override
|
|
190
|
+
// di tema definiti nel css di una pagina e consumati dal css globale):
|
|
191
|
+
// indicarle qui per nome ('--btn-primary-bg') o pattern (/^--btn-/)
|
|
192
|
+
]
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
90
197
|
// recupero metadata immagini
|
|
91
198
|
// const require = createRequire(import.meta.url);
|
|
92
199
|
// responsive-loader adapter (CJS) — use createRequire
|
|
@@ -96,8 +203,14 @@ const CopyWebpackPluginPatterns = [
|
|
|
96
203
|
/** CONFIG **/
|
|
97
204
|
|
|
98
205
|
// =>> entries
|
|
206
|
+
// NB: percorsi dalla root del progetto
|
|
99
207
|
const entries = {
|
|
100
|
-
'xxxxxx': './src/index.js'
|
|
208
|
+
'xxxxxx': './src/index.js'
|
|
209
|
+
|
|
210
|
+
// css critici inlinati nei template html: il suffisso `.critical` nel nome
|
|
211
|
+
// della entry attiva l'istanza PurgeCSS dedicata con purge stretto
|
|
212
|
+
// (vedi purgeCSSPluginCritical) e la regola dedicata in css-rules.mjs
|
|
213
|
+
// ,'xxxxxx.critical': './src/xxxxxx.critical.css'
|
|
101
214
|
};
|
|
102
215
|
|
|
103
216
|
|
|
@@ -106,7 +219,14 @@ const config = {
|
|
|
106
219
|
|
|
107
220
|
// watch: isDevelopment, // necessario se non si usa devServer
|
|
108
221
|
watchOptions: {
|
|
109
|
-
ignored: [
|
|
222
|
+
ignored: [
|
|
223
|
+
'**/build/**',
|
|
224
|
+
'**/_dev/**',
|
|
225
|
+
'**/.git/**',
|
|
226
|
+
'**/_private/**',
|
|
227
|
+
'**/node_modules/**',
|
|
228
|
+
'!**/node_modules/@massimo-cassandro/**'
|
|
229
|
+
],
|
|
110
230
|
// poll: 1000, // se necessario, risolve il problema `Error: EMFILE: too many open files, watch`
|
|
111
231
|
},
|
|
112
232
|
|
|
@@ -153,7 +273,7 @@ const config = {
|
|
|
153
273
|
extractComments: false
|
|
154
274
|
})
|
|
155
275
|
],
|
|
156
|
-
runtimeChunk: true
|
|
276
|
+
runtimeChunk: 'single', // true
|
|
157
277
|
splitChunks: {
|
|
158
278
|
cacheGroups: {
|
|
159
279
|
|
|
@@ -172,7 +292,18 @@ const config = {
|
|
|
172
292
|
},
|
|
173
293
|
|
|
174
294
|
shared: {
|
|
175
|
-
|
|
295
|
+
// solo moduli js (module.type !== 'css/mini-extract'): il css estratto
|
|
296
|
+
// resta nel chunk della entry che lo importa, così ogni asset css è
|
|
297
|
+
// autosufficiente. Necessario per PurgeCSS (`variables: true` funziona
|
|
298
|
+
// per singolo asset) e per i critical css inlinati nei template
|
|
299
|
+
//
|
|
300
|
+
// TODO: se in futuro la duplicazione di css tra le pagine dovesse crescere
|
|
301
|
+
// (componenti importati dal js di più entry), valutare un cacheGroup `styles`
|
|
302
|
+
// dedicato ai css condivisi: andranno escluse le entry `.critical` (devono
|
|
303
|
+
// restare autosufficienti) e gestite in safelist.variables le custom properties
|
|
304
|
+
// definite/consumate tra asset diversi (vedi purgecss-variables-safelist.mjs)
|
|
305
|
+
test: (module) => module.type !== 'css/mini-extract'
|
|
306
|
+
&& shared_chunk_paths.test(module.nameForCondition?.() ?? ''),
|
|
176
307
|
// test: /[\\/]node_modules[\\/]/,
|
|
177
308
|
|
|
178
309
|
// alternativa: non include nel chunk shared i path che contengono la stringa `blurhash`
|
|
@@ -196,28 +327,6 @@ const config = {
|
|
|
196
327
|
name: 'shared',
|
|
197
328
|
chunks: 'all'
|
|
198
329
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// separazione @massimo-cassandro da node_modules:
|
|
202
|
-
// mc: {
|
|
203
|
-
// test: /[\\/]node_modules\/@massimo-cassandro[\\/]/,
|
|
204
|
-
// name: 'mc',
|
|
205
|
-
// chunks: 'all'
|
|
206
|
-
// },
|
|
207
|
-
// shared: {
|
|
208
|
-
// // test: /[\\/]node_modules[\\/]/,
|
|
209
|
-
// test(module) {
|
|
210
|
-
// // `module.resource` contains the absolute path of the file on disk.
|
|
211
|
-
// // Note the usage of `path.sep` instead of / or \, for cross-platform compatibility.
|
|
212
|
-
// return (
|
|
213
|
-
// module.resource &&
|
|
214
|
-
// module.resource.includes(`${path.sep}node_modules${path.sep}`) &&
|
|
215
|
-
// !module.resource.includes(`${path.sep}@massimo-cassandro${path.sep}`)
|
|
216
|
-
// );
|
|
217
|
-
// },
|
|
218
|
-
// name: 'shareds',
|
|
219
|
-
// chunks: 'all'
|
|
220
|
-
// },
|
|
221
330
|
}
|
|
222
331
|
},
|
|
223
332
|
},
|
|
@@ -281,7 +390,7 @@ const config = {
|
|
|
281
390
|
// removeKeyHash: true, // /([a-f0-9]{32}\.?)/gi, // /(\?as_asset)$/,
|
|
282
391
|
// // rimuove i font dal manifest. Non necessari, rendono il file inutilmente grande
|
|
283
392
|
// filter: isDevelopment? undefined : (FileDescriptor) => {
|
|
284
|
-
// return /
|
|
393
|
+
// return /fonts/.test(FileDescriptor.path)? false : true;
|
|
285
394
|
// },
|
|
286
395
|
// sort: isDevelopment? undefined : (a, b) => a.name.localeCompare(b.name)
|
|
287
396
|
// }),
|
|
@@ -368,41 +477,42 @@ const config = {
|
|
|
368
477
|
);
|
|
369
478
|
},
|
|
370
479
|
raw: true,
|
|
371
|
-
//
|
|
480
|
+
// niente banner nei critical css: vengono inlinati nei template html
|
|
481
|
+
exclude: /\.critical/ // chunk name
|
|
372
482
|
}),
|
|
373
483
|
|
|
374
|
-
// =>> plugins: PurgeCSSPlugin (per ultimo
|
|
484
|
+
// =>> plugins: PurgeCSSPlugin (per ultimo, attivo in dev e prod: i problemi
|
|
485
|
+
// di purge devono emergere subito durante lo sviluppo, non solo in build)
|
|
375
486
|
// https://github.com/FullHuman/purgecss/tree/main/packages/purgecss-webpack-plugin
|
|
376
487
|
// https://purgecss.com/configuration.html
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
})
|
|
488
|
+
//
|
|
489
|
+
// NB: il plugin elabora ogni asset css SINGOLARMENTE, quindi con `variables: true`
|
|
490
|
+
// una custom property viene mantenuta solo se definita e usata nello stesso asset.
|
|
491
|
+
// Per questo:
|
|
492
|
+
// - ogni entry css importa direttamente custom-properties.css (che sostituisce
|
|
493
|
+
// postcss-jit-props: le props non usate vengono rimosse qui)
|
|
494
|
+
// - il chunk `shared` contiene solo js (vedi optimization.splitChunks)
|
|
495
|
+
// - le props dichiarate in un asset ma consumate altrove (override di tema,
|
|
496
|
+
// shadow DOM dei web components) sono gestite dalla safelist generata
|
|
497
|
+
// (vedi purgecss-variables-safelist.mjs)
|
|
498
|
+
purgeCSSPluginCritical,
|
|
499
|
+
purgeCSSPlugin,
|
|
500
|
+
|
|
501
|
+
// log dei selettori rimossi (richiede `rejected: true` nei plugin, vedi purgeCSSDebug).
|
|
502
|
+
// NB: legge `purgedStats` dalle ISTANZE del plugin, non da compilation.purgedStats
|
|
503
|
+
// (proprietà inesistente: il vecchio log basato su di essa era codice morto)
|
|
504
|
+
...(purgeCSSDebug ? [{
|
|
505
|
+
apply: (compiler) => {
|
|
506
|
+
compiler.hooks.afterEmit.tap('PurgeCSSLog', () => {
|
|
507
|
+
/* eslint-disable no-console */
|
|
508
|
+
console.log('\n--- [PurgeCSS] Selettori rimossi (critical) ---');
|
|
509
|
+
console.dir(purgeCSSPluginCritical.purgedStats, { depth: null, maxArrayLength: null });
|
|
510
|
+
console.log('\n--- [PurgeCSS] Selettori rimossi ---');
|
|
511
|
+
console.dir(purgeCSSPlugin.purgedStats, { depth: null, maxArrayLength: null });
|
|
512
|
+
/* eslint-enable no-console */
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
}] : [])
|
|
406
516
|
|
|
407
517
|
], // end plugins
|
|
408
518
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massimo-cassandro/minimo",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.2",
|
|
4
4
|
"description": "Light css framework & utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"update-version": "./dev-tools/update-version/index.mjs",
|
|
25
25
|
"upd@m": "./dev-tools/upd@m/index.mjs",
|
|
26
26
|
"svgIconsTools": "./dev-tools/svg-icons-tools/index.mjs",
|
|
27
|
-
"create-favicons": "./dev-tools/create-favicons/index.mjs"
|
|
27
|
+
"create-favicons": "./dev-tools/create-favicons/index.mjs",
|
|
28
|
+
"starter-kit": "./dev-tools/starter-kit/starter-install.sh"
|
|
28
29
|
},
|
|
29
30
|
"repository": {
|
|
30
31
|
"type": "git",
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
"npm-publish": "npm publish",
|
|
36
37
|
"upd@m": "npx upd@m",
|
|
37
38
|
"build-tokens": "node ./design-tokens/utilities/build-tokens.mjs --config ./design-tokens/tokens-config.mjs",
|
|
39
|
+
"build-margin-padding-css": "node ./scripts/build-margin-padding-css.mjs",
|
|
38
40
|
"check unresolved props": "node ./design-tokens/utilities/check-unresolved-custom-props.mjs --config ./design-tokens/tokens-config.mjs",
|
|
39
41
|
"test": "node --test \"test/**/*.test.mjs\"",
|
|
40
42
|
"checkJS": "npx tsc --noEmit -p jsconfig.json",
|