vitrify 0.10.2 → 0.10.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.
|
@@ -3,7 +3,7 @@ import { routesToPaths } from '../../helpers/routes.js';
|
|
|
3
3
|
export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath, onRendered }) => {
|
|
4
4
|
const promises = [];
|
|
5
5
|
const template = (await fs.readFile(templatePath)).toString();
|
|
6
|
-
const manifest = await fs.readFile(manifestPath);
|
|
6
|
+
const manifest = JSON.parse((await fs.readFile(manifestPath)).toString());
|
|
7
7
|
const { render, getRoutes } = await import(entryServerPath);
|
|
8
8
|
const routes = await getRoutes();
|
|
9
9
|
const paths = routesToPaths(routes).filter((i) => !i.includes(':') && !i.includes('*'));
|
|
@@ -12,7 +12,8 @@ export const prerender = async ({ outDir, templatePath, manifestPath, entryServe
|
|
|
12
12
|
logLevel: 'warn',
|
|
13
13
|
external: true,
|
|
14
14
|
inlineFonts: true,
|
|
15
|
-
preloadFonts: true
|
|
15
|
+
preloadFonts: true,
|
|
16
|
+
preload: 'swap'
|
|
16
17
|
});
|
|
17
18
|
for (const url of paths) {
|
|
18
19
|
const filename = (url.endsWith('/') ? 'index' : url.replace(/^\//g, '')) + '.html';
|
package/dist/index.js
CHANGED
|
@@ -214,18 +214,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
214
214
|
sassVariables = config.vitrify?.sass?.variables || {};
|
|
215
215
|
globalSass = config.vitrify?.sass?.global || [];
|
|
216
216
|
additionalData = config.vitrify?.sass?.additionalData || [];
|
|
217
|
-
return
|
|
218
|
-
css: {
|
|
219
|
-
preprocessorOptions: {
|
|
220
|
-
sass: {
|
|
221
|
-
additionalData: [
|
|
222
|
-
...Object.entries(sassVariables).map(([key, value]) => `${key}: ${value}`),
|
|
223
|
-
...globalSass.map((sass) => `@import '${sass}'`)
|
|
224
|
-
].join('\n')
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|
|
217
|
+
return;
|
|
229
218
|
},
|
|
230
219
|
configureServer(server) {
|
|
231
220
|
server.middlewares.use('/', (req, res, next) => {
|
|
@@ -245,7 +234,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
245
234
|
return;
|
|
246
235
|
},
|
|
247
236
|
transform: (code, id) => {
|
|
248
|
-
if (id.
|
|
237
|
+
if (id.includes('main.ts') && id.includes('vitrify')) {
|
|
249
238
|
code =
|
|
250
239
|
`${globalCss.map((css) => `import '${css}'`).join('\n')}\n` + code;
|
|
251
240
|
}
|
|
@@ -281,14 +270,12 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
281
270
|
})
|
|
282
271
|
.join('\n')}`;
|
|
283
272
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
// ].join('\n')
|
|
291
|
-
// }
|
|
273
|
+
else if (id === 'vitrify.sass') {
|
|
274
|
+
return [
|
|
275
|
+
...Object.entries(sassVariables).map(([key, value]) => `${key}: ${value}`),
|
|
276
|
+
...globalSass.map((sass) => `@import '${sass}'`)
|
|
277
|
+
].join('\n');
|
|
278
|
+
}
|
|
292
279
|
// else if (id === 'vitrify.css') {
|
|
293
280
|
// return `${globalCss.map((css) => `@import '${css}'`).join('\n')}`
|
|
294
281
|
// }
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ export const prerender = async ({
|
|
|
17
17
|
}) => {
|
|
18
18
|
const promises = []
|
|
19
19
|
const template = (await fs.readFile(templatePath)).toString()
|
|
20
|
-
const manifest = await fs.readFile(manifestPath)
|
|
20
|
+
const manifest = JSON.parse((await fs.readFile(manifestPath)).toString())
|
|
21
21
|
const { render, getRoutes } = await import(entryServerPath)
|
|
22
22
|
const routes = await getRoutes()
|
|
23
23
|
const paths = routesToPaths(routes).filter(
|
|
@@ -28,7 +28,8 @@ export const prerender = async ({
|
|
|
28
28
|
logLevel: 'warn',
|
|
29
29
|
external: true,
|
|
30
30
|
inlineFonts: true,
|
|
31
|
-
preloadFonts: true
|
|
31
|
+
preloadFonts: true,
|
|
32
|
+
preload: 'swap'
|
|
32
33
|
})
|
|
33
34
|
for (const url of paths) {
|
|
34
35
|
const filename =
|
package/src/node/index.ts
CHANGED
|
@@ -286,20 +286,7 @@ export const baseConfig = async ({
|
|
|
286
286
|
sassVariables = config.vitrify?.sass?.variables || {}
|
|
287
287
|
globalSass = config.vitrify?.sass?.global || []
|
|
288
288
|
additionalData = config.vitrify?.sass?.additionalData || []
|
|
289
|
-
return
|
|
290
|
-
css: {
|
|
291
|
-
preprocessorOptions: {
|
|
292
|
-
sass: {
|
|
293
|
-
additionalData: [
|
|
294
|
-
...Object.entries(sassVariables).map(
|
|
295
|
-
([key, value]) => `${key}: ${value}`
|
|
296
|
-
),
|
|
297
|
-
...globalSass.map((sass) => `@import '${sass}'`)
|
|
298
|
-
].join('\n')
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
289
|
+
return
|
|
303
290
|
},
|
|
304
291
|
configureServer(server) {
|
|
305
292
|
server.middlewares.use('/', (req, res, next) => {
|
|
@@ -317,7 +304,7 @@ export const baseConfig = async ({
|
|
|
317
304
|
return
|
|
318
305
|
},
|
|
319
306
|
transform: (code, id) => {
|
|
320
|
-
if (id.
|
|
307
|
+
if (id.includes('main.ts') && id.includes('vitrify')) {
|
|
321
308
|
code =
|
|
322
309
|
`${globalCss.map((css) => `import '${css}'`).join('\n')}\n` + code
|
|
323
310
|
}
|
|
@@ -351,15 +338,14 @@ export const baseConfig = async ({
|
|
|
351
338
|
return `export { ${deduped.join(',')} } from '${key}';`
|
|
352
339
|
})
|
|
353
340
|
.join('\n')}`
|
|
341
|
+
} else if (id === 'vitrify.sass') {
|
|
342
|
+
return [
|
|
343
|
+
...Object.entries(sassVariables).map(
|
|
344
|
+
([key, value]) => `${key}: ${value}`
|
|
345
|
+
),
|
|
346
|
+
...globalSass.map((sass) => `@import '${sass}'`)
|
|
347
|
+
].join('\n')
|
|
354
348
|
}
|
|
355
|
-
// else if (id === 'vitrify.sass') {
|
|
356
|
-
// return [
|
|
357
|
-
// ...Object.entries(sassVariables).map(
|
|
358
|
-
// ([key, value]) => `${key}: ${value}`
|
|
359
|
-
// ),
|
|
360
|
-
// ...globalSass.map((sass) => `@import '${sass}'`)
|
|
361
|
-
// ].join('\n')
|
|
362
|
-
// }
|
|
363
349
|
// else if (id === 'vitrify.css') {
|
|
364
350
|
// return `${globalCss.map((css) => `@import '${css}'`).join('\n')}`
|
|
365
351
|
// }
|
package/src/vite/vue/main.ts
CHANGED