@massimo-cassandro/minimo 1.11.1 → 1.12.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/dev-tools/README.md +1 -1
- package/dev-tools/update-version/index.mjs +1 -1
- package/dev-tools/update-version/src/chooser-inquirer.mjs +1 -1
- package/dev-tools/webpack-setup/starter-install.sh +149 -0
- package/dev-tools/webpack-setup/templates/__project__.code-workspace +93 -0
- package/dev-tools/webpack-setup/templates/_browserslistrc +27 -0
- package/dev-tools/webpack-setup/templates/_editorconfig +17 -0
- package/dev-tools/webpack-setup/templates/_gitignore +21 -0
- package/dev-tools/webpack-setup/templates/_prettierrc +9 -0
- package/dev-tools/webpack-setup/templates/eslint.config.mjs +31 -0
- package/dev-tools/webpack-setup/templates/jsconfig.json +22 -0
- package/dev-tools/webpack-setup/templates/package-tpl.json +37 -0
- package/dev-tools/webpack-setup/templates/stylelint.config.mjs +32 -0
- package/dev-tools/webpack-setup/webpack-modules/css-rules.mjs +177 -0
- package/dev-tools/webpack-setup/webpack-modules/get-jsConfig-aliases.mjs +33 -0
- package/dev-tools/webpack-setup/webpack-modules/postcss.config.mjs +77 -0
- package/dev-tools/webpack-setup/webpack-modules/svg-rules.mjs +154 -0
- package/dev-tools/webpack-setup/webpack-modules/svgo.config.mjs +26 -0
- package/dev-tools/webpack-setup/webpack-template.ejs +20 -0
- package/dev-tools/webpack-setup/webpack.config.mjs +585 -0
- package/package.json +5 -2
- package/snippets/ImgViewerController.php +403 -0
- package/snippets/UnsplashController.php +74 -0
- package/snippets/controllo-codice-fiscale-IT.js +48 -0
- package/snippets/controllo-partita-iva-IT.js +32 -0
- package/snippets/email-antispam.js +108 -0
- package/snippets/error-pages/bundles/TwigBundle/Exception/error.html.twig +33 -0
- package/snippets/error-pages/error-pages.js +37 -0
- package/snippets/festivita.js +101 -0
- package/snippets/minimo-form-layout.html.twig +446 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
// webpack.config.mjs
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import webpack from 'webpack';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import * as process from 'process'; // Rende 'process' disponibile nel contesto ESM
|
|
7
|
+
// import { styleText } from 'node:util';
|
|
8
|
+
// import { createRequire } from 'node:module';
|
|
9
|
+
|
|
10
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
11
|
+
import HtmlWebpackInjectPreload from '@principalstudio/html-webpack-inject-preload';
|
|
12
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
13
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
14
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
15
|
+
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
|
16
|
+
import Dotenv from 'dotenv-webpack';
|
|
17
|
+
import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts';
|
|
18
|
+
// import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
|
|
19
|
+
// import HtmlWebpackInjectAttributesPlugin from 'html-webpack-inject-attributes-plugin';
|
|
20
|
+
|
|
21
|
+
import { PurgeCSSPlugin } from 'purgecss-webpack-plugin';
|
|
22
|
+
import { globSync } from 'glob';
|
|
23
|
+
|
|
24
|
+
import { cssRules } from './webpack-modules/css-rules.mjs';
|
|
25
|
+
import { getJsConfigAliases } from './webpack-modules/get-jsConfig-aliases.mjs';
|
|
26
|
+
import { svgRules } from './webpack-modules/svg-rules.mjs';
|
|
27
|
+
|
|
28
|
+
// --- config ---
|
|
29
|
+
const isDevelopment = process.env.NODE_ENV === 'development'
|
|
30
|
+
,__filename = fileURLToPath(import.meta.url)
|
|
31
|
+
,__dirname = path.dirname(__filename)
|
|
32
|
+
,useSass = false
|
|
33
|
+
,inlineCssInDevMode = true
|
|
34
|
+
,useSvgo = true
|
|
35
|
+
,useSvgr = false // svg per react
|
|
36
|
+
,svgoConfig = useSvgo? (await import('./webpack-modules/svgo.config.mjs')).default : null
|
|
37
|
+
,postcssConfig_path = path.resolve(__dirname, './webpack-modules/postcss.config.mjs')
|
|
38
|
+
,output_dir = path.resolve(__dirname, '../build')
|
|
39
|
+
// ,output_dir = isDevelopment? '_dev' : 'build' // symfony
|
|
40
|
+
,favicons_path = 'frontend/favicons/output'
|
|
41
|
+
,favicons_path_regexp = new RegExp(favicons_path) // source pattern per le favicons (regexp o null)
|
|
42
|
+
,jsConfigAliases = getJsConfigAliases(path.resolve(__dirname, './jsconfig.json'))
|
|
43
|
+
,packageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, './package.json'), 'utf-8'))
|
|
44
|
+
// ,manifest_shared_seed = {}
|
|
45
|
+
;
|
|
46
|
+
|
|
47
|
+
// path delle directory da utilizzare nel chunk `shared`
|
|
48
|
+
const sep = '[\\\\/]'; // stringa che produce [\\/] nel pattern
|
|
49
|
+
const shared_chunk_paths =
|
|
50
|
+
new RegExp([
|
|
51
|
+
'node_modules',
|
|
52
|
+
'frontend/src/js',
|
|
53
|
+
'frontend/src/web-components',
|
|
54
|
+
'frontend/src/components',
|
|
55
|
+
].map(p => `${sep}${p.replace(/\//g, sep)}${sep}`).join('|')
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// hash: https://medium.com/@web_developer/hash-vs-chunkhash-vs-contenthash-e94d38a32208
|
|
60
|
+
|
|
61
|
+
// =>> CopyWebpackPlugin patterns
|
|
62
|
+
// (null o array vuoto per disattivare)
|
|
63
|
+
// https://github.com/webpack/copy-webpack-plugin/tree/main?tab=readme-ov-file#copy-webpack-plugin
|
|
64
|
+
const CopyWebpackPluginPatterns = [
|
|
65
|
+
{
|
|
66
|
+
from: 'src/favicons/output/icon-*.png',
|
|
67
|
+
to: '[name][ext]'
|
|
68
|
+
},
|
|
69
|
+
// {
|
|
70
|
+
// from: '*.webp',
|
|
71
|
+
// to: 'imgs/[name].[contenthash].[ext]',
|
|
72
|
+
// context: './source/path/', // viene rimosso nella copia
|
|
73
|
+
// globOptions: {
|
|
74
|
+
// dot: true,
|
|
75
|
+
// gitignore: true,
|
|
76
|
+
// ignore: [ '**/.DS_Store' ]
|
|
77
|
+
// }
|
|
78
|
+
// },
|
|
79
|
+
// {
|
|
80
|
+
// from: 'src/php',
|
|
81
|
+
// to: 'php',
|
|
82
|
+
// globOptions: {
|
|
83
|
+
// dot: true,
|
|
84
|
+
// gitignore: true,
|
|
85
|
+
// ignore: [ '**/.DS_Store', ...(isDevelopment ? [] : [ '**/init-dev.php' ]) ]
|
|
86
|
+
// }
|
|
87
|
+
// }
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
// recupero metadata immagini
|
|
91
|
+
// const require = createRequire(import.meta.url);
|
|
92
|
+
// responsive-loader adapter (CJS) — use createRequire
|
|
93
|
+
// const responsiveLoaderSharp = require('responsive-loader/sharp');
|
|
94
|
+
|
|
95
|
+
/******************************/
|
|
96
|
+
/** CONFIG **/
|
|
97
|
+
|
|
98
|
+
// =>> entries
|
|
99
|
+
const entries = {
|
|
100
|
+
'xxxxxx': './src/index.js' // NB percorso dalla root
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
const config = {
|
|
105
|
+
mode: isDevelopment ? 'development' : 'production',
|
|
106
|
+
|
|
107
|
+
// watch: isDevelopment, // necessario se non si usa devServer
|
|
108
|
+
watchOptions: {
|
|
109
|
+
ignored: [ 'build', '**/node_modules', '.git', '_private' ],
|
|
110
|
+
// poll: 1000, // se necessario, risolve il problema `Error: EMFILE: too many open files, watch`
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
// https://webpack.js.org/configuration/dotenv/
|
|
114
|
+
dotenv: {
|
|
115
|
+
prefix: 'APP_',
|
|
116
|
+
dir: '/',
|
|
117
|
+
template: ['.env', '.env.development'] //, '.env.local', '.env.[mode]', '.env.[mode].local'],
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
devtool: isDevelopment ? 'inline-source-map' : false,
|
|
121
|
+
|
|
122
|
+
entry: entries,
|
|
123
|
+
|
|
124
|
+
output: {
|
|
125
|
+
path: output_dir,
|
|
126
|
+
filename: '[name].[contenthash].js',
|
|
127
|
+
publicPath: '/',
|
|
128
|
+
// publicPath: isDevelopment? '/' : './', // per devServer, nel caso in cui l'output di produzione non sia sulla root
|
|
129
|
+
clean: !isDevelopment
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
/* SYMFONY:
|
|
133
|
+
output: {
|
|
134
|
+
path: path.resolve(__dirname, `../public/${output_dir}` ),
|
|
135
|
+
// filename: '[name].js',
|
|
136
|
+
filename: '[name].[contenthash].js',
|
|
137
|
+
publicPath: `/${output_dir}/`,
|
|
138
|
+
clean: false //!isDevelopment,
|
|
139
|
+
},
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
// =>> optimization
|
|
143
|
+
optimization: {
|
|
144
|
+
minimize: !isDevelopment,
|
|
145
|
+
minimizer: [
|
|
146
|
+
new CssMinimizerPlugin(),
|
|
147
|
+
new TerserPlugin({
|
|
148
|
+
terserOptions: {
|
|
149
|
+
output: {
|
|
150
|
+
comments: /^!/
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
extractComments: false
|
|
154
|
+
})
|
|
155
|
+
],
|
|
156
|
+
runtimeChunk: true,
|
|
157
|
+
splitChunks: {
|
|
158
|
+
cacheGroups: {
|
|
159
|
+
|
|
160
|
+
icons: {
|
|
161
|
+
test(module) {
|
|
162
|
+
return (
|
|
163
|
+
module.resource &&
|
|
164
|
+
module.resource.includes(`${path.sep}src${path.sep}icons${path.sep}`) &&
|
|
165
|
+
!module.resource.includes(`${path.sep}node_modules${path.sep}`)
|
|
166
|
+
);
|
|
167
|
+
},
|
|
168
|
+
name: 'icons',
|
|
169
|
+
chunks: 'all',
|
|
170
|
+
priority: 20,
|
|
171
|
+
enforce: true
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
shared: {
|
|
175
|
+
test: shared_chunk_paths,
|
|
176
|
+
// test: /[\\/]node_modules[\\/]/,
|
|
177
|
+
|
|
178
|
+
// alternativa: non include nel chunk shared i path che contengono la stringa `blurhash`
|
|
179
|
+
// test: /[\\/]node_modules[\\/](?!.*blurhash)/i,
|
|
180
|
+
|
|
181
|
+
// alternativa: verifica se l'import ha una query specifica (?exclude-shared-chunk)
|
|
182
|
+
// test(module) {
|
|
183
|
+
// const resource = module.nameForCondition && module.nameForCondition();
|
|
184
|
+
// if (!resource) return false;
|
|
185
|
+
|
|
186
|
+
// // Verifica se è in node_modules
|
|
187
|
+
// const isNodeModule = /[\\/]node_modules[\\/]/.test(resource);
|
|
188
|
+
|
|
189
|
+
// // module.resource è il percorso completo + query string
|
|
190
|
+
// const hasExcludeQuery = module.resource && module.resource.includes('exclude-shared-chunk');
|
|
191
|
+
|
|
192
|
+
// // Include nel chunk shared solo se è un node_module E NON ha la query
|
|
193
|
+
// return isNodeModule && !hasExcludeQuery;
|
|
194
|
+
// },
|
|
195
|
+
// test: /[\\/]node_modules[\\/](?!.*blurhash)(?!.*@massimo-cassandro\/unsplash-page)/i,
|
|
196
|
+
name: 'shared',
|
|
197
|
+
chunks: 'all'
|
|
198
|
+
}
|
|
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
|
+
}
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
// =>> performance
|
|
226
|
+
performance: {
|
|
227
|
+
hints: false,
|
|
228
|
+
maxEntrypointSize: 512000,
|
|
229
|
+
maxAssetSize: 512000
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
// =>> devServer
|
|
233
|
+
devServer: {
|
|
234
|
+
historyApiFallback: true,
|
|
235
|
+
static: {
|
|
236
|
+
directory: path.join(__dirname, '/'),
|
|
237
|
+
serveIndex: true
|
|
238
|
+
},
|
|
239
|
+
open: { app: { name: 'Google Chrome' } },
|
|
240
|
+
compress: true,
|
|
241
|
+
hot: true,
|
|
242
|
+
port: 5700
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
// =>> plugins
|
|
246
|
+
plugins: [
|
|
247
|
+
// =>> plugins: Dotenv
|
|
248
|
+
new Dotenv({
|
|
249
|
+
path: isDevelopment ? './.env.development' : './.env',
|
|
250
|
+
expand: true,
|
|
251
|
+
ignoreStub: true,
|
|
252
|
+
allowEmptyValues: true
|
|
253
|
+
}),
|
|
254
|
+
new webpack.ProvidePlugin({
|
|
255
|
+
process: 'process/browser.js'
|
|
256
|
+
}),
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
// =>> plugins: RemoveEmptyScriptsPlugin
|
|
260
|
+
new RemoveEmptyScriptsPlugin({
|
|
261
|
+
enabled: !isDevelopment,
|
|
262
|
+
verbose: true
|
|
263
|
+
}),
|
|
264
|
+
|
|
265
|
+
// =>> plugins: CopyWebpackPlugin
|
|
266
|
+
...(
|
|
267
|
+
CopyWebpackPluginPatterns != null && CopyWebpackPluginPatterns.length > 0
|
|
268
|
+
? [
|
|
269
|
+
new CopyWebpackPlugin({
|
|
270
|
+
patterns: CopyWebpackPluginPatterns
|
|
271
|
+
})
|
|
272
|
+
]
|
|
273
|
+
: []
|
|
274
|
+
),
|
|
275
|
+
|
|
276
|
+
// =>> plugins: WebpackManifestPlugin
|
|
277
|
+
// new WebpackManifestPlugin({
|
|
278
|
+
// fileName: path.join(output_dir, 'manifest.json'), // sf: fileName: 'manifest.json', // scrive in output.path
|
|
279
|
+
// // basePath: item.source_dirname
|
|
280
|
+
// // removeKeyHash: /(^(_assets\/(?!(fonts\/))))|((\?as_asset)$)/,
|
|
281
|
+
// removeKeyHash: true, // /([a-f0-9]{32}\.?)/gi, // /(\?as_asset)$/,
|
|
282
|
+
// // rimuove i font dal manifest. Non necessari, rendono il file inutilmente grande
|
|
283
|
+
// filter: isDevelopment? undefined : (FileDescriptor) => {
|
|
284
|
+
// return /_fonts/.test(FileDescriptor.path)? false : true;
|
|
285
|
+
// },
|
|
286
|
+
// sort: isDevelopment? undefined : (a, b) => a.name.localeCompare(b.name)
|
|
287
|
+
// }),
|
|
288
|
+
|
|
289
|
+
// =>> plugins: MiniCssExtractPlugin
|
|
290
|
+
new MiniCssExtractPlugin({
|
|
291
|
+
filename: '[name].[contenthash].css',
|
|
292
|
+
chunkFilename: '[id].[contenthash].css',
|
|
293
|
+
ignoreOrder: true
|
|
294
|
+
}),
|
|
295
|
+
|
|
296
|
+
// =>> plugins: HtmlWebpackPlugin (manifest)
|
|
297
|
+
new HtmlWebpackPlugin({
|
|
298
|
+
filename: 'manifest.webmanifest',
|
|
299
|
+
template: path.resolve(__dirname, './src/favicons/output/manifest.webmanifest.ejs'),
|
|
300
|
+
inject: false,
|
|
301
|
+
minify: false //!isDevelopment
|
|
302
|
+
}),
|
|
303
|
+
|
|
304
|
+
// =>> plugins: HtmlWebpackPlugin
|
|
305
|
+
new HtmlWebpackPlugin({
|
|
306
|
+
filename: 'index.html',
|
|
307
|
+
template: path.resolve(__dirname, './src/tpl/index.ejs'),
|
|
308
|
+
inject: 'body',
|
|
309
|
+
title: 'XXXXX',
|
|
310
|
+
minify: !isDevelopment
|
|
311
|
+
}),
|
|
312
|
+
|
|
313
|
+
// =>> plugins: HtmlWebpackInjectAttributesPlugin
|
|
314
|
+
// new HtmlWebpackInjectAttributesPlugin({
|
|
315
|
+
// // La funzione riceve un oggetto con gli attributi del tag corrente
|
|
316
|
+
// media: (tag) => {
|
|
317
|
+
// // console.log(tag.attributes);
|
|
318
|
+
// // 'tag.attributes.href' contiene il percorso del file CSS generato
|
|
319
|
+
// if (tag.attributes.href && tag.attributes.rel === 'stylesheet' && /^(\.\/memo\.).*(\.css)$/.test(tag.attributes.href)) {
|
|
320
|
+
// return 'print';
|
|
321
|
+
// }
|
|
322
|
+
// return null;
|
|
323
|
+
// }
|
|
324
|
+
// }),
|
|
325
|
+
|
|
326
|
+
// =>> plugins: HtmlWebpackInjectPreload
|
|
327
|
+
// https://github.com/principalstudio/html-webpack-inject-preload
|
|
328
|
+
...(isDevelopment
|
|
329
|
+
? []
|
|
330
|
+
: [
|
|
331
|
+
new HtmlWebpackInjectPreload({
|
|
332
|
+
files: [
|
|
333
|
+
{
|
|
334
|
+
match: /.*-latin-(?!(ext-)).*\.woff2$/,
|
|
335
|
+
attributes: { as: 'font', type: 'font/woff2', crossorigin: true }
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
match: /.*\.css$/,
|
|
339
|
+
attributes: { as: 'style' }
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
match: /.*\.js$/,
|
|
343
|
+
attributes: { as: 'script' }
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
})
|
|
347
|
+
]
|
|
348
|
+
),
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
// =>> plugins: BannerPlugin
|
|
352
|
+
new webpack.BannerPlugin({
|
|
353
|
+
banner: () => {
|
|
354
|
+
|
|
355
|
+
const start_year = 2026,
|
|
356
|
+
current_year = new Date().toLocaleString('en-UK', { year: 'numeric' }),
|
|
357
|
+
year = [
|
|
358
|
+
start_year,
|
|
359
|
+
...(current_year > start_year? [current_year] : [])
|
|
360
|
+
].join('-'),
|
|
361
|
+
|
|
362
|
+
vers = packageJson.version.split('.').slice(0,-1).join('.');
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
'/*!\n' +
|
|
366
|
+
` * ${packageJson.name} v.${vers} - Massimo Cassandro ${year}\n` +
|
|
367
|
+
' */\n'
|
|
368
|
+
);
|
|
369
|
+
},
|
|
370
|
+
raw: true,
|
|
371
|
+
// exclude: /\.critical/ // chunk name
|
|
372
|
+
}),
|
|
373
|
+
|
|
374
|
+
// =>> plugins: PurgeCSSPlugin (per ultimo)
|
|
375
|
+
// https://github.com/FullHuman/purgecss/tree/main/packages/purgecss-webpack-plugin
|
|
376
|
+
// https://purgecss.com/configuration.html
|
|
377
|
+
// https://github.com/isaacs/node-glob#readme
|
|
378
|
+
new PurgeCSSPlugin({
|
|
379
|
+
|
|
380
|
+
// css da pulire
|
|
381
|
+
paths: globSync(
|
|
382
|
+
|
|
383
|
+
// path.resolve(__dirname, '@minimo/**/!(*.module).css'),
|
|
384
|
+
path.resolve(__dirname, '@src/**/*.{css,js,ejs}'),
|
|
385
|
+
// path.resolve(__dirname, '@src/**/*.js'),
|
|
386
|
+
// path.resolve(__dirname, '@app/**/*.ejs'),
|
|
387
|
+
// path.join(__dirname, './templates/**/*.twig')
|
|
388
|
+
|
|
389
|
+
{ nodir: true }
|
|
390
|
+
), // .filter(filePath => !filePath.endsWith('.module.css'));
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
variables: false, // Analizza le variabili custom
|
|
395
|
+
safelist: {
|
|
396
|
+
standard: ['body', 'html', 'button', 'a'],
|
|
397
|
+
deep: [/^btn/],
|
|
398
|
+
greedy: []
|
|
399
|
+
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
// verbose: true,
|
|
403
|
+
// rejected: true,
|
|
404
|
+
// stdout: true
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
], // end plugins
|
|
408
|
+
|
|
409
|
+
module: {
|
|
410
|
+
rules: [
|
|
411
|
+
|
|
412
|
+
// =>> rules: js / jsx
|
|
413
|
+
{
|
|
414
|
+
test: /\.jsx?$/,
|
|
415
|
+
oneOf: [
|
|
416
|
+
{
|
|
417
|
+
resourceQuery: /as_lib/, // utilizzo come libreria
|
|
418
|
+
type: 'asset/resource',
|
|
419
|
+
generator: {
|
|
420
|
+
filename: 'libs/[name].[contenthash][ext]'
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
exclude: /node_modules/,
|
|
425
|
+
use: {
|
|
426
|
+
loader: 'babel-loader',
|
|
427
|
+
options: {
|
|
428
|
+
presets: [['@babel/preset-env', { targets: 'defaults' }]]
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
]
|
|
433
|
+
},
|
|
434
|
+
|
|
435
|
+
// =>> template ejs
|
|
436
|
+
{
|
|
437
|
+
test: /\.ejs$/i,
|
|
438
|
+
use: [
|
|
439
|
+
{
|
|
440
|
+
loader: 'ejs-loader',
|
|
441
|
+
options: {
|
|
442
|
+
esModule: false // Necessario per far sì che il require restituisca la stringa correttamente
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
]
|
|
446
|
+
},
|
|
447
|
+
|
|
448
|
+
// =>> rules: html files
|
|
449
|
+
{
|
|
450
|
+
test: /(\.html?)$/i,
|
|
451
|
+
oneOf: [
|
|
452
|
+
{
|
|
453
|
+
type: 'asset/resource',
|
|
454
|
+
resourceQuery: /as_asset/,
|
|
455
|
+
generator: {
|
|
456
|
+
filename: '[name].[contenthash][ext]'
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
loader: 'html-loader'
|
|
461
|
+
}
|
|
462
|
+
]
|
|
463
|
+
},
|
|
464
|
+
|
|
465
|
+
// =>> rules: favicons
|
|
466
|
+
{
|
|
467
|
+
test: /\.(?:ico|png|svg|webmanifest)$/i,
|
|
468
|
+
type: 'asset/resource',
|
|
469
|
+
include: favicons_path_regexp?? undefined,
|
|
470
|
+
generator: {
|
|
471
|
+
filename: '[name][ext]?_=[contenthash]'
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
// =>> raw txt / md files
|
|
478
|
+
{
|
|
479
|
+
test: /(\.(txt|md))$/i,
|
|
480
|
+
type: 'asset/source'
|
|
481
|
+
},
|
|
482
|
+
|
|
483
|
+
// =>> rules: svg
|
|
484
|
+
...svgRules({useSvgo: useSvgo, svgoConfig: svgoConfig, useSvgr: useSvgr, favicons_path_regexp: favicons_path_regexp?? null }),
|
|
485
|
+
|
|
486
|
+
// =>> rules: Images / pdf
|
|
487
|
+
{
|
|
488
|
+
test: /\.(?:gif|png|jpg|jpeg|webp|avif|pdf)$/i,
|
|
489
|
+
oneOf: [
|
|
490
|
+
|
|
491
|
+
// './img.jpg?metadata'
|
|
492
|
+
// {
|
|
493
|
+
// resourceQuery: /metadata/,
|
|
494
|
+
// // 'javascript/auto' è OBBLIGATORIO qui per impedire a Webpack 5 di trattarlo come un asset nativo duplicato
|
|
495
|
+
// type: 'javascript/auto',
|
|
496
|
+
// use: [
|
|
497
|
+
// {
|
|
498
|
+
// loader: 'responsive-loader',
|
|
499
|
+
// options: {
|
|
500
|
+
// // Sharp è necessario per leggere i metadati velocemente
|
|
501
|
+
// adapter: responsiveLoaderSharp,
|
|
502
|
+
|
|
503
|
+
// // solo i dati del file originale
|
|
504
|
+
// // disable: true,
|
|
505
|
+
// sizes: [99999999], // forza responsive-loader a ricalcolare le dimensioni reali
|
|
506
|
+
|
|
507
|
+
// esModule: true,
|
|
508
|
+
|
|
509
|
+
// // Manteniamo i nomi file consistenti
|
|
510
|
+
// name: '[name].[contenthash][ext]',
|
|
511
|
+
// outputPath: 'imgs',
|
|
512
|
+
// publicPath: path.join((isDevelopment? '/_dev/' : '/build/'), 'imgs')
|
|
513
|
+
// },
|
|
514
|
+
// },
|
|
515
|
+
// ],
|
|
516
|
+
// },
|
|
517
|
+
|
|
518
|
+
{
|
|
519
|
+
type: 'asset/resource',
|
|
520
|
+
exclude: favicons_path_regexp?? undefined,
|
|
521
|
+
generator: {
|
|
522
|
+
filename: 'imgs/[name].[contenthash][ext]',
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
],
|
|
526
|
+
},
|
|
527
|
+
|
|
528
|
+
// =>> Video
|
|
529
|
+
{
|
|
530
|
+
test: /\.(?:mp4|webm)$/i,
|
|
531
|
+
// type: 'asset/resource',
|
|
532
|
+
type: 'javascript/auto',
|
|
533
|
+
use: [
|
|
534
|
+
{
|
|
535
|
+
loader: 'file-loader',
|
|
536
|
+
options: {
|
|
537
|
+
name: '[name].[contenthash][ext]',
|
|
538
|
+
outputPath: 'video/',
|
|
539
|
+
esModule: false,
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
]
|
|
543
|
+
},
|
|
544
|
+
|
|
545
|
+
// =>> rules: Fonts
|
|
546
|
+
{
|
|
547
|
+
test: /\.(woff2?|eot|ttf|otf)$/,
|
|
548
|
+
type: 'asset/resource',
|
|
549
|
+
generator: {
|
|
550
|
+
filename: 'fonts/[name].[contenthash][ext]'
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
|
|
554
|
+
// =>> rules: css / scss
|
|
555
|
+
...cssRules({isDevelopment: isDevelopment, useSass: useSass, inlineCssInDevMode: inlineCssInDevMode, postcssConfig_path: postcssConfig_path})
|
|
556
|
+
] // end rules
|
|
557
|
+
}, // end module
|
|
558
|
+
|
|
559
|
+
// =>> resolve
|
|
560
|
+
resolve: {
|
|
561
|
+
fallback: {
|
|
562
|
+
fs: false,
|
|
563
|
+
util: false,
|
|
564
|
+
process: 'process/browser.js'
|
|
565
|
+
},
|
|
566
|
+
modules: [ './', './node_modules' ],
|
|
567
|
+
extensions: [ '.tsx', '.ts', '.js', '.mjs', '.cjs', '.jsx', '.json', '.scss', '.css' ],
|
|
568
|
+
alias: {
|
|
569
|
+
...jsConfigAliases
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
|
|
573
|
+
// =>> stats
|
|
574
|
+
// stats: {
|
|
575
|
+
// assets: false,
|
|
576
|
+
// modules: false,
|
|
577
|
+
// chunks: false,
|
|
578
|
+
// errors: true, // Mostra solo gli errori
|
|
579
|
+
// errorDetails: false, // Disabilita i dettagli troppo prolissi
|
|
580
|
+
// moduleTrace: false,
|
|
581
|
+
// },
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
export default config;
|
|
585
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@massimo-cassandro/minimo",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Light css framework & utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -56,7 +56,10 @@
|
|
|
56
56
|
"design-tokens/_src/**/*.{tokens.json,tokens.jsonc,mjs,js,md}",
|
|
57
57
|
"design-tokens/utilities/**/*.{mjs,md}",
|
|
58
58
|
"charts/**/*.{js,md}",
|
|
59
|
-
"dev-tools/**/*.{js,mjs,md,html}"
|
|
59
|
+
"dev-tools/**/*.{js,mjs,md,html}",
|
|
60
|
+
"dev-tools/webpack-setup/**/*.{js,mjs,md,sh,json,ejs}",
|
|
61
|
+
"dev-tools/webpack-setup/**/_*",
|
|
62
|
+
"snippets/**/*.{php,js,md,twig}"
|
|
60
63
|
],
|
|
61
64
|
"peerDependenciesMeta": {
|
|
62
65
|
"@svgdotjs/svg.js": {
|