vitrify 0.5.9 → 0.6.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 CHANGED
@@ -15,7 +15,7 @@ cli
15
15
  .action(async (options) => {
16
16
  const { build } = await import('./build.js');
17
17
  let appDir;
18
- let prerender, onRenderedHooks;
18
+ let prerender;
19
19
  if (options.appDir) {
20
20
  if (options.appDir.slice(-1) !== '/')
21
21
  options.appDir += '/';
@@ -68,15 +68,14 @@ cli
68
68
  ...args,
69
69
  outDir: new URL('ssr/server/', baseOutDir).pathname
70
70
  });
71
- ({ prerender, onRenderedHooks } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
71
+ ({ prerender } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
72
72
  prerender({
73
73
  outDir: new URL('static/', baseOutDir).pathname,
74
74
  templatePath: new URL('static/index.html', baseOutDir).pathname,
75
75
  manifestPath: new URL('static/ssr-manifest.json', baseOutDir)
76
76
  .pathname,
77
77
  entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir)
78
- .pathname,
79
- onRenderedHooks
78
+ .pathname
80
79
  });
81
80
  break;
82
81
  default:
@@ -134,11 +134,6 @@ const fastifySsrPlugin = async (fastify, options, done) => {
134
134
  let html = template
135
135
  .replace(`<!--preload-links-->`, preloadLinks)
136
136
  .replace(`<!--app-html-->`, appHtml);
137
- if (options.onRendered?.length) {
138
- for (const ssrFunction of options.onRendered) {
139
- html = ssrFunction(html, ssrContext);
140
- }
141
- }
142
137
  res.code(200);
143
138
  res.type('text/html');
144
139
  res.send(html);
@@ -1,12 +1,19 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { routesToPaths } from '../../helpers/routes.js';
3
- export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath, onRenderedHooks }) => {
3
+ export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath }) => {
4
4
  const promises = [];
5
5
  const template = (await fs.readFile(templatePath)).toString();
6
6
  const manifest = await fs.readFile(manifestPath);
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('*'));
10
+ const critters = new (await import('critters')).default({
11
+ path: outDir,
12
+ logLevel: 'warn',
13
+ external: true,
14
+ inlineFonts: true,
15
+ preloadFonts: true
16
+ });
10
17
  for (const url of paths) {
11
18
  const filename = (url.endsWith('/') ? 'index' : url.replace(/^\//g, '')) + '.html';
12
19
  console.log(`Generating ${filename}`);
@@ -18,11 +25,7 @@ export const prerender = async ({ outDir, templatePath, manifestPath, entryServe
18
25
  let html = template
19
26
  .replace(`<!--preload-links-->`, preloadLinks)
20
27
  .replace(`<!--app-html-->`, appHtml);
21
- if (onRenderedHooks?.length) {
22
- for (const ssrFunction of onRenderedHooks) {
23
- html = ssrFunction(html, ssrContext);
24
- }
25
- }
28
+ html = await critters.process(html);
26
29
  promises.push(fs.writeFile(outDir + filename, html, 'utf-8'));
27
30
  }
28
31
  return Promise.all(promises);
@@ -1,12 +1,11 @@
1
1
  import fastify from 'fastify';
2
- export const createApp = ({ onSetup, appDir, baseUrl, onRendered, fastifyPlugin, vitrifyDir, mode }) => {
2
+ export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, vitrifyDir, mode }) => {
3
3
  const app = fastify({
4
4
  logger: true
5
5
  });
6
6
  app.register(fastifyPlugin, {
7
7
  baseUrl,
8
8
  appDir,
9
- onRendered,
10
9
  vitrifyDir,
11
10
  mode
12
11
  });
package/dist/index.js CHANGED
@@ -18,7 +18,8 @@ const internalServerModules = [
18
18
  '@fastify/static',
19
19
  '@fastify/middie',
20
20
  '@fastify',
21
- 'node'
21
+ 'node',
22
+ 'critters'
22
23
  ];
23
24
  const configPluginMap = {
24
25
  quasar: () => import('./plugins/quasar.js').then((module) => module.QuasarPlugin)
@@ -29,7 +30,11 @@ const manualChunkNames = [
29
30
  'fastify-csr-plugin',
30
31
  'server'
31
32
  ];
32
- const manualChunks = (id) => {
33
+ const moduleChunks = {
34
+ vue: ['vue', '@vue'],
35
+ quasar: ['quasar']
36
+ };
37
+ const manualChunks = (id, api) => {
33
38
  if (id.includes('vitrify/src/vite/')) {
34
39
  const name = id.split('/').at(-1)?.split('.').at(0);
35
40
  if (name && manualChunkNames.includes(name))
@@ -39,6 +44,9 @@ const manualChunks = (id) => {
39
44
  return VIRTUAL_MODULES.find((name) => id.includes(name));
40
45
  }
41
46
  else if (id.includes('node_modules')) {
47
+ const name = Object.entries(moduleChunks).find(([chunkName, moduleNames]) => moduleNames.some((name) => id.includes(`${name}/`)));
48
+ if (name)
49
+ return name[0];
42
50
  return 'vendor';
43
51
  }
44
52
  };
@@ -132,13 +140,13 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
132
140
  console.log('No vitrify.config.(ts|js) file found, using defaults');
133
141
  vitrifyConfig = {};
134
142
  }
135
- // const localPackages = ['vue', 'vue-router', '@vue/server-renderer']
136
- const localPackages = [];
143
+ const localPackages = ['vue', 'vue-router', '@vue/server-renderer'];
144
+ // const localPackages: string[] = []
137
145
  const cliPackages = [];
138
146
  const packageUrls = vitrifyConfig.vitrify?.urls?.packages || {};
139
147
  await (async () => {
140
148
  for (const val of localPackages)
141
- packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, appDir)));
149
+ packageUrls[val] = getPkgJsonDir(new URL(resolve(val, appDir)));
142
150
  })();
143
151
  // await (async () => {
144
152
  // for (const val of cliPackages)
@@ -528,3 +536,4 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
528
536
  return mergeConfig(config, vitrifyConfig);
529
537
  };
530
538
  export const vitrifyDir = new URL('..', import.meta.url);
539
+ export { prerender } from './frameworks/vue/prerender.js';
@@ -42,9 +42,9 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
42
42
  const { ssr: transformSsr } = options || {};
43
43
  code = code
44
44
  .replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
45
- .replaceAll('__QUASAR_SSR_SERVER__', 'import.meta.env.SSR')
46
- .replaceAll('__QUASAR_SSR_CLIENT__', '!import.meta.env.SSR')
47
- .replaceAll('__QUASAR_SSR_PWA__', pwa ? '!import.meta.env.SSR' : 'false');
45
+ .replaceAll('__QUASAR_SSR_SERVER__', ssr === 'server' ? 'import.meta.env.SSR' : 'false')
46
+ .replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '!import.meta.env.SSR' : 'false')
47
+ .replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '!import.meta.env.SSR' : 'false');
48
48
  return code;
49
49
  }
50
50
  },
@@ -180,10 +180,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
180
180
  {
181
181
  find: 'quasar/src',
182
182
  replacement: new URL('node_modules/quasar/src/', config.vitrify?.urls?.app).pathname
183
- },
184
- {
185
- find: new RegExp('^quasar$'),
186
- replacement: 'virtual:quasar'
187
183
  }
188
184
  // {
189
185
  // find: 'quasar',
@@ -206,7 +202,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
206
202
  ]
207
203
  },
208
204
  optimizeDeps: {
209
- // exclude: ['quasar']
205
+ exclude: ['quasar']
210
206
  },
211
207
  define: {
212
208
  __DEV__: process.env.NODE_ENV !== 'production' || true,
@@ -231,7 +227,11 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
231
227
  config: async (config, env) => ({
232
228
  resolve: {
233
229
  alias: [
234
- // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
230
+ {
231
+ find: new RegExp('^quasar$'),
232
+ replacement: 'virtual:quasar'
233
+ }
234
+ // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
235
235
  ]
236
236
  }
237
237
  }),
@@ -1,5 +1,4 @@
1
1
  import type { FastifyPluginCallback, FastifyRequest, FastifyReply } from 'fastify';
2
- import type { OnRenderedHook } from '../../vitrify-config.js';
3
2
  import type { ViteDevServer } from 'vite';
4
3
  export interface FastifySsrOptions {
5
4
  baseUrl?: string;
@@ -9,7 +8,6 @@ export interface FastifySsrOptions {
9
8
  appDir?: URL;
10
9
  publicDir?: URL;
11
10
  productName?: string;
12
- onRendered?: OnRenderedHook[];
13
11
  mode?: string;
14
12
  }
15
13
  declare const fastifyCsrPlugin: FastifyPluginCallback<FastifySsrOptions>;
@@ -1,5 +1,4 @@
1
1
  import type { FastifyPluginCallback, FastifyRequest, FastifyReply } from 'fastify';
2
- import type { OnRenderedHook } from '../../vitrify-config.js';
3
2
  import type { ViteDevServer } from 'vite';
4
3
  export interface FastifySsrOptions {
5
4
  baseUrl?: string;
@@ -9,7 +8,6 @@ export interface FastifySsrOptions {
9
8
  appDir?: URL;
10
9
  publicDir?: URL;
11
10
  productName?: string;
12
- onRendered?: OnRenderedHook[];
13
11
  mode?: string;
14
12
  }
15
13
  declare const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions>;
@@ -1,8 +1,6 @@
1
- import type { OnRenderedHook } from '../../vitrify-config.js';
2
- export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath, onRenderedHooks }: {
1
+ export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath }: {
3
2
  outDir: string;
4
3
  templatePath: string;
5
4
  manifestPath: string;
6
5
  entryServerPath: string;
7
- onRenderedHooks: OnRenderedHook[];
8
6
  }) => Promise<void[]>;
@@ -1,13 +1,12 @@
1
1
  /// <reference types="node" />
2
2
  import type { FastifyInstance } from 'fastify';
3
- import type { OnRenderedHook, OnSetupFile } from '../../vitrify-config.js';
3
+ import type { OnSetupFile } from '../../vitrify-config.js';
4
4
  import type { FastifyCsrPlugin } from './fastify-csr-plugin.js';
5
5
  import type { FastifySsrPlugin } from './fastify-ssr-plugin.js';
6
- export declare const createApp: ({ onSetup, appDir, baseUrl, onRendered, fastifyPlugin, vitrifyDir, mode }: {
6
+ export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, vitrifyDir, mode }: {
7
7
  onSetup: OnSetupFile[];
8
8
  appDir: URL;
9
9
  baseUrl?: string | undefined;
10
- onRendered?: OnRenderedHook[] | undefined;
11
10
  fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin;
12
11
  vitrifyDir?: URL | undefined;
13
12
  mode: string;
@@ -15,4 +15,5 @@ export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode,
15
15
  debug?: boolean | undefined;
16
16
  }) => Promise<InlineConfig>;
17
17
  export declare const vitrifyDir: URL;
18
+ export { prerender } from './frameworks/vue/prerender.js';
18
19
  export type { VitrifyConfig, VitrifyPlugin, VitrifyContext, BootFunction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.5.9",
3
+ "version": "0.6.1",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Pre-configured Vite CLI for your framework",
@@ -56,6 +56,7 @@
56
56
  "@fastify/static": "^6.4.0",
57
57
  "@quasar/extras": "^1.14.1",
58
58
  "@vitejs/plugin-vue": "^3.0.0-alpha.1",
59
+ "@vue/server-renderer": "^3.2.37",
59
60
  "builtin-modules": "^3.3.0",
60
61
  "cac": "^6.7.12",
61
62
  "chalk": "^5.0.1",
@@ -24,7 +24,7 @@ cli
24
24
  .action(async (options) => {
25
25
  const { build } = await import('./build.js')
26
26
  let appDir: URL
27
- let prerender, onRenderedHooks
27
+ let prerender
28
28
  if (options.appDir) {
29
29
  if (options.appDir.slice(-1) !== '/') options.appDir += '/'
30
30
  appDir = new URL(`file://${options.appDir}`)
@@ -84,7 +84,7 @@ cli
84
84
  ...args,
85
85
  outDir: new URL('ssr/server/', baseOutDir).pathname
86
86
  })
87
- ;({ prerender, onRenderedHooks } = await import(
87
+ ;({ prerender } = await import(
88
88
  new URL('ssr/server/prerender.mjs', baseOutDir).pathname
89
89
  ))
90
90
  prerender({
@@ -93,8 +93,7 @@ cli
93
93
  manifestPath: new URL('static/ssr-manifest.json', baseOutDir)
94
94
  .pathname,
95
95
  entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir)
96
- .pathname,
97
- onRenderedHooks
96
+ .pathname
98
97
  })
99
98
  break
100
99
  default:
@@ -4,7 +4,6 @@ import type {
4
4
  FastifyReply
5
5
  } from 'fastify'
6
6
  import fastifyStatic from '@fastify/static'
7
- import type { OnRenderedHook } from '../../vitrify-config.js'
8
7
  import type { ViteDevServer } from 'vite'
9
8
 
10
9
  export interface FastifySsrOptions {
@@ -19,7 +18,6 @@ export interface FastifySsrOptions {
19
18
  appDir?: URL
20
19
  publicDir?: URL
21
20
  productName?: string
22
- onRendered?: OnRenderedHook[]
23
21
  mode?: string
24
22
  }
25
23
 
@@ -5,7 +5,6 @@ import type {
5
5
  } from 'fastify'
6
6
  import fastifyStatic from '@fastify/static'
7
7
  import { readFileSync } from 'fs'
8
- import type { OnRenderedHook } from '../../vitrify-config.js'
9
8
  import { componentsModules, collectCss } from '../../helpers/collect-css-ssr.js'
10
9
  import type { ViteDevServer } from 'vite'
11
10
 
@@ -21,7 +20,6 @@ export interface FastifySsrOptions {
21
20
  appDir?: URL
22
21
  publicDir?: URL
23
22
  productName?: string
24
- onRendered?: OnRenderedHook[]
25
23
  mode?: string
26
24
  }
27
25
 
@@ -189,12 +187,6 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
189
187
  .replace(`<!--preload-links-->`, preloadLinks)
190
188
  .replace(`<!--app-html-->`, appHtml)
191
189
 
192
- if (options.onRendered?.length) {
193
- for (const ssrFunction of options.onRendered) {
194
- html = ssrFunction(html, ssrContext)
195
- }
196
- }
197
-
198
190
  res.code(200)
199
191
  res.type('text/html')
200
192
  res.send(html)
@@ -1,19 +1,16 @@
1
1
  import { promises as fs } from 'fs'
2
2
  import { routesToPaths } from '../../helpers/routes.js'
3
- import type { OnRenderedHook } from '../../vitrify-config.js'
4
3
 
5
4
  export const prerender = async ({
6
5
  outDir,
7
6
  templatePath,
8
7
  manifestPath,
9
- entryServerPath,
10
- onRenderedHooks
8
+ entryServerPath
11
9
  }: {
12
10
  outDir: string
13
11
  templatePath: string
14
12
  manifestPath: string
15
13
  entryServerPath: string
16
- onRenderedHooks: OnRenderedHook[]
17
14
  }) => {
18
15
  const promises = []
19
16
  const template = (await fs.readFile(templatePath)).toString()
@@ -23,6 +20,13 @@ export const prerender = async ({
23
20
  const paths = routesToPaths(routes).filter(
24
21
  (i) => !i.includes(':') && !i.includes('*')
25
22
  )
23
+ const critters = new (await import('critters')).default({
24
+ path: outDir,
25
+ logLevel: 'warn',
26
+ external: true,
27
+ inlineFonts: true,
28
+ preloadFonts: true
29
+ })
26
30
  for (const url of paths) {
27
31
  const filename =
28
32
  (url.endsWith('/') ? 'index' : url.replace(/^\//g, '')) + '.html'
@@ -37,11 +41,7 @@ export const prerender = async ({
37
41
  .replace(`<!--preload-links-->`, preloadLinks)
38
42
  .replace(`<!--app-html-->`, appHtml)
39
43
 
40
- if (onRenderedHooks?.length) {
41
- for (const ssrFunction of onRenderedHooks) {
42
- html = ssrFunction(html, ssrContext)
43
- }
44
- }
44
+ html = await critters.process(html)
45
45
 
46
46
  promises.push(fs.writeFile(outDir + filename, html, 'utf-8'))
47
47
  }
@@ -2,7 +2,7 @@ import type { FastifyInstance } from 'fastify'
2
2
  import fastify from 'fastify'
3
3
  import type { ViteDevServer } from 'vite'
4
4
  import { getCliDir, getCliViteDir } from '../../app-urls.js'
5
- import type { OnRenderedHook, OnSetupFile } from '../../vitrify-config.js'
5
+ import type { OnSetupFile } from '../../vitrify-config.js'
6
6
  import type { FastifyCsrPlugin } from './fastify-csr-plugin.js'
7
7
  import type { FastifySsrPlugin } from './fastify-ssr-plugin.js'
8
8
 
@@ -10,7 +10,6 @@ export const createApp = ({
10
10
  onSetup,
11
11
  appDir,
12
12
  baseUrl,
13
- onRendered,
14
13
  fastifyPlugin,
15
14
  vitrifyDir,
16
15
  mode
@@ -18,7 +17,6 @@ export const createApp = ({
18
17
  onSetup: OnSetupFile[]
19
18
  appDir: URL
20
19
  baseUrl?: string
21
- onRendered?: OnRenderedHook[]
22
20
  fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin
23
21
  vitrifyDir?: URL
24
22
  mode: string
@@ -30,7 +28,6 @@ export const createApp = ({
30
28
  app.register(fastifyPlugin, {
31
29
  baseUrl,
32
30
  appDir,
33
- onRendered,
34
31
  vitrifyDir,
35
32
  mode
36
33
  })
package/src/node/index.ts CHANGED
@@ -33,7 +33,8 @@ const internalServerModules = [
33
33
  '@fastify/static',
34
34
  '@fastify/middie',
35
35
  '@fastify',
36
- 'node'
36
+ 'node',
37
+ 'critters'
37
38
  ]
38
39
 
39
40
  const configPluginMap: Record<string, () => Promise<VitrifyPlugin>> = {
@@ -47,7 +48,12 @@ const manualChunkNames = [
47
48
  'fastify-csr-plugin',
48
49
  'server'
49
50
  ]
50
- const manualChunks: ManualChunksOption = (id: string) => {
51
+
52
+ const moduleChunks = {
53
+ vue: ['vue', '@vue'],
54
+ quasar: ['quasar']
55
+ }
56
+ const manualChunks: ManualChunksOption = (id, api) => {
51
57
  if (id.includes('vitrify/src/vite/')) {
52
58
  const name = id.split('/').at(-1)?.split('.').at(0)
53
59
  if (name && manualChunkNames.includes(name)) return name
@@ -56,6 +62,10 @@ const manualChunks: ManualChunksOption = (id: string) => {
56
62
  ) {
57
63
  return VIRTUAL_MODULES.find((name) => id.includes(name))
58
64
  } else if (id.includes('node_modules')) {
65
+ const name = Object.entries(moduleChunks).find(([chunkName, moduleNames]) =>
66
+ moduleNames.some((name) => id.includes(`${name}/`))
67
+ )
68
+ if (name) return name[0]
59
69
  return 'vendor'
60
70
  }
61
71
  }
@@ -194,14 +204,14 @@ export const baseConfig = async ({
194
204
  vitrifyConfig = {}
195
205
  }
196
206
 
197
- // const localPackages = ['vue', 'vue-router', '@vue/server-renderer']
198
- const localPackages: string[] = []
207
+ const localPackages = ['vue', 'vue-router', '@vue/server-renderer']
208
+ // const localPackages: string[] = []
199
209
  const cliPackages = []
200
210
  const packageUrls: Record<string, URL> =
201
211
  vitrifyConfig.vitrify?.urls?.packages || {}
202
212
  await (async () => {
203
213
  for (const val of localPackages)
204
- packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, appDir)))
214
+ packageUrls[val] = getPkgJsonDir(new URL(resolve(val, appDir)))
205
215
  })()
206
216
 
207
217
  // await (async () => {
@@ -612,5 +622,5 @@ export const baseConfig = async ({
612
622
  }
613
623
 
614
624
  export const vitrifyDir = new URL('..', import.meta.url)
615
-
625
+ export { prerender } from './frameworks/vue/prerender.js'
616
626
  export type { VitrifyConfig, VitrifyPlugin, VitrifyContext, BootFunction }
@@ -93,11 +93,17 @@ export const QuasarPlugin: VitrifyPlugin = async ({
93
93
  const { ssr: transformSsr } = options || {}
94
94
  code = code
95
95
  .replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
96
- .replaceAll('__QUASAR_SSR_SERVER__', 'import.meta.env.SSR')
97
- .replaceAll('__QUASAR_SSR_CLIENT__', '!import.meta.env.SSR')
96
+ .replaceAll(
97
+ '__QUASAR_SSR_SERVER__',
98
+ ssr === 'server' ? 'import.meta.env.SSR' : 'false'
99
+ )
100
+ .replaceAll(
101
+ '__QUASAR_SSR_CLIENT__',
102
+ ssr ? '!import.meta.env.SSR' : 'false'
103
+ )
98
104
  .replaceAll(
99
105
  '__QUASAR_SSR_PWA__',
100
- pwa ? '!import.meta.env.SSR' : 'false'
106
+ ssr && pwa ? '!import.meta.env.SSR' : 'false'
101
107
  )
102
108
 
103
109
  return code
@@ -256,10 +262,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
256
262
  'node_modules/quasar/src/',
257
263
  config.vitrify?.urls?.app
258
264
  ).pathname
259
- },
260
- {
261
- find: new RegExp('^quasar$'),
262
- replacement: 'virtual:quasar'
263
265
  }
264
266
  // {
265
267
  // find: 'quasar',
@@ -282,7 +284,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
282
284
  ]
283
285
  },
284
286
  optimizeDeps: {
285
- // exclude: ['quasar']
287
+ exclude: ['quasar']
286
288
  },
287
289
  define: {
288
290
  __DEV__: process.env.NODE_ENV !== 'production' || true,
@@ -307,6 +309,10 @@ export const QuasarPlugin: VitrifyPlugin = async ({
307
309
  config: async (config, env) => ({
308
310
  resolve: {
309
311
  alias: [
312
+ {
313
+ find: new RegExp('^quasar$'),
314
+ replacement: 'virtual:quasar'
315
+ }
310
316
  // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
311
317
  ]
312
318
  }
@@ -1,7 +1,7 @@
1
1
  import { createApp } from '../../../node/frameworks/vue/server.js'
2
2
  import { getAppDir } from '../../../node/app-urls.js'
3
3
  // import { setup } from 'virtual:fastify-setup'
4
- import { onRendered, onSetup } from 'virtual:vitrify-hooks'
4
+ import { onSetup } from 'virtual:vitrify-hooks'
5
5
  import { fastifyCsrPlugin } from './fastify-csr-plugin.js'
6
6
  import type { ViteDevServer } from 'vite'
7
7
 
@@ -16,7 +16,6 @@ export const setupApp = async () => {
16
16
  onSetup,
17
17
  appDir,
18
18
  baseUrl,
19
- onRendered,
20
19
  fastifyPlugin: fastifyCsrPlugin,
21
20
  // vitrifyDir,
22
21
  mode: import.meta.env.MODE
@@ -1,7 +1,7 @@
1
1
  import { createApp } from '../../../node/frameworks/vue/server.js'
2
2
  import { getAppDir } from '../../../node/app-urls.js'
3
3
  // import { setup } from 'virtual:fastify-setup'
4
- import { onRendered, onSetup } from 'virtual:vitrify-hooks'
4
+ import { onSetup } from 'virtual:vitrify-hooks'
5
5
  import { fastifySsrPlugin } from './fastify-ssr-plugin.js'
6
6
  import type { ViteDevServer } from 'vite'
7
7
 
@@ -16,7 +16,6 @@ export const setupApp = async () => {
16
16
  onSetup,
17
17
  appDir,
18
18
  baseUrl,
19
- onRendered,
20
19
  fastifyPlugin: fastifySsrPlugin,
21
20
  // vitrifyDir,
22
21
  mode: import.meta.env.MODE
@@ -5,7 +5,7 @@ import type { FastifyInstance } from 'fastify'
5
5
  // import { ApolloClients } from '@vue/apollo-composable'
6
6
  // import serialize from 'serialize-javascript'
7
7
 
8
- import { onSetup } from 'virtual:vitrify-hooks'
8
+ import { onSetup, onRendered } from 'virtual:vitrify-hooks'
9
9
 
10
10
  export const setup = async ({ fastify }: { fastify: FastifyInstance }) => {
11
11
  if (onSetup?.length) {
@@ -67,6 +67,12 @@ export async function render(url, manifest, ssrContext) {
67
67
  // request.
68
68
  const preloadLinks = renderPreloadLinks(ctx.modules, manifest)
69
69
 
70
+ if (onRendered?.length) {
71
+ for (const ssrFunction of onRendered) {
72
+ html = ssrFunction(html, ssrContext)
73
+ }
74
+ }
75
+
70
76
  return [html, preloadLinks]
71
77
  }
72
78
 
@@ -1,4 +1,3 @@
1
1
  import { fastifySsrPlugin } from '../../../node/frameworks/vue/fastify-ssr-plugin.js'
2
- import { onRendered } from 'virtual:vitrify-hooks'
3
2
 
4
- export { fastifySsrPlugin, onRendered }
3
+ export { fastifySsrPlugin }
@@ -1,4 +1,3 @@
1
1
  import { prerender } from '../../../node/frameworks/vue/prerender.js'
2
- import { onRendered } from 'virtual:vitrify-hooks'
3
2
 
4
- export { prerender, onRendered }
3
+ export { prerender }
@@ -1,23 +1,4 @@
1
- // import { createApp } from '../../../node/frameworks/vue/server.js'
2
- // import { getAppDir } from '../../../node/app-urls.js'
3
- // import { setup } from 'virtual:fastify-setup'
4
- // import { onRendered, onSetup } from 'virtual:vitrify-hooks'
5
- // import { fastifySsrPlugin } from './fastify-ssr-plugin.js'
6
1
  import { setupApp } from './app.js'
7
- // import * as staticImports from 'virtual:static-imports'
8
- // const appDir = getPkgJsonDir(import.meta.url)
9
- // const getString = (str?: string) => str
10
- // let baseUrl = getString(__BASE_URL__)
11
- // const appDir = getAppDir()
12
-
13
- // const app = createApp({
14
- // onSetup,
15
- // appDir,
16
- // baseUrl,
17
- // onRendered,
18
- // fastifySsrPlugin,
19
- // mode: import.meta.env.MODE
20
- // })
21
2
 
22
3
  const app = await setupApp()
23
4