vitrify 0.17.18 → 0.18.1
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/bin/cli.js +22 -3
- package/dist/index.js +17 -0
- package/dist/plugins/quasar/unocss/index.js +30 -1
- package/package.json +1 -1
- package/src/node/bin/cli.ts +25 -4
- package/src/node/index.ts +23 -0
- package/src/node/plugins/quasar/unocss/index.ts +30 -1
package/dist/bin/cli.js
CHANGED
|
@@ -3,6 +3,8 @@ import cac from 'cac';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { getAppDir, parsePath } from '../app-urls.js';
|
|
5
5
|
import { printHttpServerUrls, exitLogs } from '../helpers/logger.js';
|
|
6
|
+
import { build as esbuild } from 'esbuild';
|
|
7
|
+
import { readdir } from 'fs/promises';
|
|
6
8
|
const cli = cac('vitrify');
|
|
7
9
|
cli
|
|
8
10
|
.command('build')
|
|
@@ -72,9 +74,6 @@ cli
|
|
|
72
74
|
outDir: fileURLToPath(new URL('ssr/server/', baseOutDir))
|
|
73
75
|
});
|
|
74
76
|
({ prerender, onRendered } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
|
|
75
|
-
// ;({ prerender, onRendered } = await import(
|
|
76
|
-
// fileURLToPath(new URL('ssr/server/prerender.mjs', baseOutDir))
|
|
77
|
-
// ))
|
|
78
77
|
prerender({
|
|
79
78
|
outDir: fileURLToPath(new URL('static/', baseOutDir)),
|
|
80
79
|
templatePath: fileURLToPath(new URL('static/index.html', baseOutDir)),
|
|
@@ -165,6 +164,26 @@ cli.command('run <file>').action(async (file, options) => {
|
|
|
165
164
|
const filePath = new URL(file, `file://${process.cwd()}/`);
|
|
166
165
|
await run(fileURLToPath(filePath));
|
|
167
166
|
});
|
|
167
|
+
cli.command('minify <dir>').action(async (dir, options) => {
|
|
168
|
+
const files = await readdir(fileURLToPath(new URL(dir, `file://${process.cwd()}/`)));
|
|
169
|
+
let counter = 0;
|
|
170
|
+
for (const file of files) {
|
|
171
|
+
if (file.endsWith('.mjs')) {
|
|
172
|
+
await esbuild({
|
|
173
|
+
absWorkingDir: fileURLToPath(new URL(dir, `file://${process.cwd()}/`)),
|
|
174
|
+
entryPoints: [file],
|
|
175
|
+
minify: true,
|
|
176
|
+
minifyIdentifiers: true,
|
|
177
|
+
minifySyntax: true,
|
|
178
|
+
minifyWhitespace: true,
|
|
179
|
+
outfile: file,
|
|
180
|
+
allowOverwrite: true
|
|
181
|
+
});
|
|
182
|
+
counter++;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
console.log(`Minified ${counter} files`);
|
|
186
|
+
});
|
|
168
187
|
// Default
|
|
169
188
|
cli.command('').action((command, options) => {
|
|
170
189
|
cli.outputHelp();
|
package/dist/index.js
CHANGED
|
@@ -375,6 +375,23 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
375
375
|
return `export default ${JSON.stringify(vitrifyConfig)}`;
|
|
376
376
|
}
|
|
377
377
|
return null;
|
|
378
|
+
},
|
|
379
|
+
transformIndexHtml: {
|
|
380
|
+
order: 'post',
|
|
381
|
+
handler: (html) => {
|
|
382
|
+
const headContent = html.match(/<head>(.|\n)*<\/head>/);
|
|
383
|
+
if (headContent) {
|
|
384
|
+
const headLinks = headContent[0].match(/<link (.*?)>/g);
|
|
385
|
+
if (headLinks) {
|
|
386
|
+
const headWithoutLinks = headContent[0].replaceAll(/<link (.*?)>\n?/g, '');
|
|
387
|
+
const headWithSortedLinks = headWithoutLinks.replace('</head>', [
|
|
388
|
+
...headLinks.sort((link) => (link.includes('.css') ? -1 : 0)),
|
|
389
|
+
'</head>'
|
|
390
|
+
].join('\n'));
|
|
391
|
+
return html.replace(/<head>(.|\n)*<\/head>/, headWithSortedLinks);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
378
395
|
}
|
|
379
396
|
},
|
|
380
397
|
Components({
|
|
@@ -104,7 +104,36 @@ const toKebabCase = (str) => str
|
|
|
104
104
|
?.map((x) => x.toLowerCase())
|
|
105
105
|
.join('-') ?? '';
|
|
106
106
|
const componentsSafelistMap = {
|
|
107
|
-
QSelect: ['q-list', 'q-item', 'q-virtual-scroll', 'q-menu']
|
|
107
|
+
QSelect: ['q-list', 'q-item', 'q-virtual-scroll', 'q-menu'],
|
|
108
|
+
QPageSticky: [
|
|
109
|
+
'relative-position',
|
|
110
|
+
'fixed',
|
|
111
|
+
'fixed-full',
|
|
112
|
+
'fullscreen',
|
|
113
|
+
'fixed-center',
|
|
114
|
+
'fixed-bottom',
|
|
115
|
+
'fixed-left',
|
|
116
|
+
'fixed-right',
|
|
117
|
+
'fixed-top',
|
|
118
|
+
'fixed-top-left',
|
|
119
|
+
'fixed-top-right',
|
|
120
|
+
'fixed-bottom-left',
|
|
121
|
+
'fixed-bottom-right',
|
|
122
|
+
'absolute',
|
|
123
|
+
'absolute-full',
|
|
124
|
+
'absolute-center',
|
|
125
|
+
'absolute-bottom',
|
|
126
|
+
'absolute-left',
|
|
127
|
+
'absolute-right',
|
|
128
|
+
'absolute-top',
|
|
129
|
+
'absolute-top-left',
|
|
130
|
+
'absolute-top-right',
|
|
131
|
+
'absolute-bottom-left',
|
|
132
|
+
'absolute-bottom-right',
|
|
133
|
+
'vertical-top',
|
|
134
|
+
'vertical-middle',
|
|
135
|
+
'vertical-bottom'
|
|
136
|
+
]
|
|
108
137
|
};
|
|
109
138
|
const pluginSafelistMap = {
|
|
110
139
|
BottomSheet: [
|
package/package.json
CHANGED
package/src/node/bin/cli.ts
CHANGED
|
@@ -3,9 +3,11 @@ import cac from 'cac'
|
|
|
3
3
|
import { fileURLToPath } from 'url'
|
|
4
4
|
import { getAppDir, parsePath } from '../app-urls.js'
|
|
5
5
|
import { printHttpServerUrls, exitLogs } from '../helpers/logger.js'
|
|
6
|
+
import { build as esbuild } from 'esbuild'
|
|
6
7
|
import type { ResolvedConfig, ViteDevServer } from 'vite'
|
|
7
8
|
import type { Server } from 'net'
|
|
8
9
|
import type { FastifyInstance } from 'fastify'
|
|
10
|
+
import { readdir } from 'fs/promises'
|
|
9
11
|
|
|
10
12
|
const cli = cac('vitrify')
|
|
11
13
|
cli
|
|
@@ -87,10 +89,6 @@ cli
|
|
|
87
89
|
new URL('ssr/server/prerender.mjs', baseOutDir).pathname
|
|
88
90
|
))
|
|
89
91
|
|
|
90
|
-
// ;({ prerender, onRendered } = await import(
|
|
91
|
-
// fileURLToPath(new URL('ssr/server/prerender.mjs', baseOutDir))
|
|
92
|
-
// ))
|
|
93
|
-
|
|
94
92
|
prerender({
|
|
95
93
|
outDir: fileURLToPath(new URL('static/', baseOutDir)),
|
|
96
94
|
templatePath: fileURLToPath(new URL('static/index.html', baseOutDir)),
|
|
@@ -188,6 +186,29 @@ cli.command('run <file>').action(async (file, options) => {
|
|
|
188
186
|
await run(fileURLToPath(filePath))
|
|
189
187
|
})
|
|
190
188
|
|
|
189
|
+
cli.command('minify <dir>').action(async (dir, options) => {
|
|
190
|
+
const files = await readdir(
|
|
191
|
+
fileURLToPath(new URL(dir, `file://${process.cwd()}/`))
|
|
192
|
+
)
|
|
193
|
+
let counter = 0
|
|
194
|
+
for (const file of files) {
|
|
195
|
+
if (file.endsWith('.mjs')) {
|
|
196
|
+
await esbuild({
|
|
197
|
+
absWorkingDir: fileURLToPath(new URL(dir, `file://${process.cwd()}/`)),
|
|
198
|
+
entryPoints: [file],
|
|
199
|
+
minify: true,
|
|
200
|
+
minifyIdentifiers: true,
|
|
201
|
+
minifySyntax: true,
|
|
202
|
+
minifyWhitespace: true,
|
|
203
|
+
outfile: file,
|
|
204
|
+
allowOverwrite: true
|
|
205
|
+
})
|
|
206
|
+
counter++
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
console.log(`Minified ${counter} files`)
|
|
210
|
+
})
|
|
211
|
+
|
|
191
212
|
// Default
|
|
192
213
|
cli.command('').action((command, options) => {
|
|
193
214
|
cli.outputHelp()
|
package/src/node/index.ts
CHANGED
|
@@ -472,6 +472,29 @@ export const baseConfig = async ({
|
|
|
472
472
|
return `export default ${JSON.stringify(vitrifyConfig)}`
|
|
473
473
|
}
|
|
474
474
|
return null
|
|
475
|
+
},
|
|
476
|
+
transformIndexHtml: {
|
|
477
|
+
order: 'post',
|
|
478
|
+
handler: (html) => {
|
|
479
|
+
const headContent = html.match(/<head>(.|\n)*<\/head>/)
|
|
480
|
+
if (headContent) {
|
|
481
|
+
const headLinks = headContent[0].match(/<link (.*?)>/g)
|
|
482
|
+
if (headLinks) {
|
|
483
|
+
const headWithoutLinks = headContent[0].replaceAll(
|
|
484
|
+
/<link (.*?)>\n?/g,
|
|
485
|
+
''
|
|
486
|
+
)
|
|
487
|
+
const headWithSortedLinks = headWithoutLinks.replace(
|
|
488
|
+
'</head>',
|
|
489
|
+
[
|
|
490
|
+
...headLinks.sort((link) => (link.includes('.css') ? -1 : 0)),
|
|
491
|
+
'</head>'
|
|
492
|
+
].join('\n')
|
|
493
|
+
)
|
|
494
|
+
return html.replace(/<head>(.|\n)*<\/head>/, headWithSortedLinks)
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
475
498
|
}
|
|
476
499
|
},
|
|
477
500
|
Components({
|
|
@@ -203,7 +203,36 @@ const toKebabCase = (str: string) =>
|
|
|
203
203
|
|
|
204
204
|
const componentsSafelistMap: Partial<Record<keyof QuasarComponents, string[]>> =
|
|
205
205
|
{
|
|
206
|
-
QSelect: ['q-list', 'q-item', 'q-virtual-scroll', 'q-menu']
|
|
206
|
+
QSelect: ['q-list', 'q-item', 'q-virtual-scroll', 'q-menu'],
|
|
207
|
+
QPageSticky: [
|
|
208
|
+
'relative-position',
|
|
209
|
+
'fixed',
|
|
210
|
+
'fixed-full',
|
|
211
|
+
'fullscreen',
|
|
212
|
+
'fixed-center',
|
|
213
|
+
'fixed-bottom',
|
|
214
|
+
'fixed-left',
|
|
215
|
+
'fixed-right',
|
|
216
|
+
'fixed-top',
|
|
217
|
+
'fixed-top-left',
|
|
218
|
+
'fixed-top-right',
|
|
219
|
+
'fixed-bottom-left',
|
|
220
|
+
'fixed-bottom-right',
|
|
221
|
+
'absolute',
|
|
222
|
+
'absolute-full',
|
|
223
|
+
'absolute-center',
|
|
224
|
+
'absolute-bottom',
|
|
225
|
+
'absolute-left',
|
|
226
|
+
'absolute-right',
|
|
227
|
+
'absolute-top',
|
|
228
|
+
'absolute-top-left',
|
|
229
|
+
'absolute-top-right',
|
|
230
|
+
'absolute-bottom-left',
|
|
231
|
+
'absolute-bottom-right',
|
|
232
|
+
'vertical-top',
|
|
233
|
+
'vertical-middle',
|
|
234
|
+
'vertical-bottom'
|
|
235
|
+
]
|
|
207
236
|
}
|
|
208
237
|
|
|
209
238
|
const pluginSafelistMap: Partial<Record<keyof QuasarPlugins, string[]>> = {
|