vitrify 0.6.18 → 0.7.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/dist/bin/dev.js CHANGED
@@ -77,15 +77,18 @@ ssr, framework = 'vue', host, appDir, publicDir }) {
77
77
  let setup;
78
78
  let server;
79
79
  let onRendered;
80
+ let vitrifyConfig;
80
81
  console.log(`Development mode: ${ssr ? ssr : 'csr'}`);
81
82
  if (ssr) {
82
83
  const entryUrl = ssr === 'fastify'
83
84
  ? new URL('src/vite/fastify/entry.ts', cliDir).pathname
84
85
  : new URL(`src/vite/${framework}/ssr/app.ts`, cliDir).pathname;
85
- ({ setup, onRendered } = await vite.ssrLoadModule(entryUrl));
86
+ ({ setup, onRendered, vitrifyConfig } = await vite.ssrLoadModule(entryUrl));
87
+ console.log(vitrifyConfig);
86
88
  const app = fastify({
87
89
  logger: false,
88
- https: vite.config.server.https
90
+ https: vite.config.server.https,
91
+ ...vitrifyConfig.vitrify?.ssr?.fastify
89
92
  });
90
93
  if (process.env)
91
94
  process.env.MODE = 'development';
package/dist/index.js CHANGED
@@ -169,12 +169,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
169
169
  catch (e) {
170
170
  console.error('package.json not found');
171
171
  }
172
- const ssrTransformCustomDir = () => {
173
- return {
174
- props: [],
175
- needRuntime: true
176
- };
177
- };
178
172
  const frameworkPlugins = [];
179
173
  for (const framework of Object.keys(configPluginMap)) {
180
174
  if (Object.keys(vitrifyConfig).includes(framework)) {
@@ -201,27 +195,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
201
195
  ...vitrifyConfig.vitrify.ssr.serverModules
202
196
  ];
203
197
  const plugins = [
204
- vuePlugin({
205
- // compiler: await import('vue/compiler-sfc'),
206
- // template: {
207
- // ssr: !!ssr,
208
- // compilerOptions: {
209
- // directiveTransforms: {
210
- // 'close-popup': ssrTransformCustomDir,
211
- // intersection: ssrTransformCustomDir,
212
- // ripple: ssrTransformCustomDir,
213
- // mutation: ssrTransformCustomDir,
214
- // morph: ssrTransformCustomDir,
215
- // scroll: ssrTransformCustomDir,
216
- // 'scroll-fire': ssrTransformCustomDir,
217
- // 'touch-hold': ssrTransformCustomDir,
218
- // 'touch-pan': ssrTransformCustomDir,
219
- // 'touch-repeat': ssrTransformCustomDir,
220
- // 'touch-swipe': ssrTransformCustomDir
221
- // }
222
- // }
223
- // }
224
- }),
198
+ vuePlugin(),
225
199
  ...frameworkPlugins,
226
200
  {
227
201
  name: 'vitrify-setup',
@@ -236,21 +210,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
236
210
  sassVariables = config.vitrify?.sass?.variables || {};
237
211
  globalSass = config.vitrify?.sass?.global || [];
238
212
  additionalData = config.vitrify?.sass?.additionalData || [];
239
- return {
240
- // css: {
241
- // preprocessorOptions: {
242
- // sass: {
243
- // additionalData: [
244
- // ...Object.entries(sassVariables).map(
245
- // ([key, value]) => `${key}: ${value}`
246
- // )
247
- // // ...additionalData
248
- // // config.css?.preprocessorOptions?.sass.additionalData
249
- // ].join('\n')
250
- // }
251
- // }
252
- // }
253
- };
213
+ return {};
254
214
  },
255
215
  configureServer(server) {
256
216
  server.middlewares.use('/', (req, res, next) => {
@@ -290,24 +250,21 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
290
250
  .join(', ')}]
291
251
  export const onSetup = []
292
252
  ${onSetupFiles
293
- .map((url, index) => `import ${url.pathname
294
- .replaceAll('/', '')
295
- .replaceAll('.', '')} from '${url.pathname}'; onSetup.push(${url.pathname
296
- .replaceAll('/', '')
297
- .replaceAll('.', '')})`)
253
+ .map((url, index) => {
254
+ const varName = url.pathname
255
+ .replaceAll('/', '')
256
+ .replaceAll('.', '')
257
+ .replaceAll('-', '');
258
+ return `import ${varName} from '${url.pathname}'; onSetup.push(${varName})`;
259
+ })
298
260
  .join('\n')}`;
299
- // export const onSetup = [${onSetupHooks
300
- // .map((fn) => `${String(fn)}`)
301
- // .join(', ')}]`
302
- /**
303
- * CSS imports in virtual files do not seem to work. Using transform() instead
304
- */
305
- // } else if (id === 'virtual:global-css') {
306
- // return `${globalCss.map((css) => `import '${css}'`).join('\n')}`
307
261
  }
308
262
  else if (id === 'virtual:static-imports') {
309
263
  return `${Object.entries(staticImports)
310
- .map(([key, value]) => `export { ${value.join(',')} } from '${key}';`)
264
+ .map(([key, value]) => {
265
+ const deduped = [...new Set(value)];
266
+ return `export { ${deduped.join(',')} } from '${key}';`;
267
+ })
311
268
  .join('\n')}`;
312
269
  }
313
270
  else if (id === 'vitrify.sass') {
@@ -330,16 +287,16 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
330
287
  plugins.unshift({
331
288
  name: 'html-transform',
332
289
  enforce: 'pre',
333
- transform: (code, id) => {
334
- if (id.endsWith('App.vue')) {
335
- code =
336
- code +
337
- `<style lang="sass">
338
- // do not remove, required for additionalData import
339
- </style>`;
340
- }
341
- return code;
342
- },
290
+ // transform: (code, id) => {
291
+ // if (id.endsWith('App.vue')) {
292
+ // code =
293
+ // code +
294
+ // `<style lang="sass">
295
+ // // do not remove, required for additionalData import
296
+ // </style>`
297
+ // }
298
+ // return code
299
+ // },
343
300
  transformIndexHtml: {
344
301
  enforce: 'pre',
345
302
  transform: (html) => {
@@ -396,17 +353,10 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
396
353
  find: new RegExp('^vue$'),
397
354
  replacement: new URL('./dist/vue.runtime.esm-bundler.js', packageUrls['vue']).pathname
398
355
  },
399
- // {
400
- // find: new RegExp('^vue/server-renderer$'),
401
- // replacement: 'vue/server-renderer/index.mjs'
402
- // },
403
356
  {
404
357
  find: new RegExp('^vue-router$'),
405
358
  replacement: new URL('./dist/vue-router.esm-bundler.js', packageUrls['vue-router']).pathname
406
359
  }
407
- // { find: 'vue', replacement: packageUrls['vue'].pathname },
408
- // { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
409
- // { find: 'vitrify', replacement: cliDir.pathname }
410
360
  ];
411
361
  if (mode === 'development' && vitrifyConfig.vitrify?.dev?.alias)
412
362
  alias.push(...vitrifyConfig.vitrify.dev.alias);
@@ -430,25 +380,16 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
430
380
  ],
431
381
  external,
432
382
  output: {
433
- minifyInternalExports: !debug,
383
+ minifyInternalExports: false,
434
384
  entryFileNames: '[name].mjs',
435
385
  chunkFileNames: '[name].mjs',
436
386
  format: 'es',
437
387
  manualChunks
438
- // manualChunks: (id) => {
439
- // if (id.includes('vitrify/src/vite/')) {
440
- // const name = id.split('/').at(-1)?.split('.').at(0)
441
- // if (name && manualChunks.includes(name)) return name
442
- // } else if (id.includes('node_modules')) {
443
- // return 'vendor'
444
- // }
445
- // }
446
388
  }
447
389
  };
448
390
  // Create a SSR bundle
449
391
  noExternal = [
450
392
  new RegExp(`^(?!(${[...builtinModules, ...serverModules].join('|')}))`)
451
- // new RegExp(`^(?!.*(${[...builtinModules, ...serverModules].join('|')}))`)
452
393
  ];
453
394
  }
454
395
  else if (ssr === 'fastify') {
@@ -462,14 +403,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
462
403
  chunkFileNames: '[name].mjs',
463
404
  format: 'es',
464
405
  manualChunks
465
- // manualChunks: (id) => {
466
- // if (id.includes('vitrify/src/vite/')) {
467
- // const name = id.split('/').at(-1)?.split('.').at(0)
468
- // if (name && manualChunks.includes(name)) return name
469
- // } else if (id.includes('node_modules')) {
470
- // return 'vendor'
471
- // }
472
- // }
473
406
  }
474
407
  };
475
408
  // Create a SSR bundle
@@ -480,13 +413,9 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
480
413
  else {
481
414
  rollupOptions = {
482
415
  ...rollupOptions,
483
- // input: [
484
- // new URL('index.html', frameworkDir).pathname
485
- // // new URL('csr/server.ts', frameworkDir).pathname
486
- // ],
487
416
  external,
488
417
  output: {
489
- minifyInternalExports: !debug,
418
+ minifyInternalExports: false,
490
419
  entryFileNames: '[name].mjs',
491
420
  chunkFileNames: '[name].mjs',
492
421
  format: 'es',
@@ -495,7 +424,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
495
424
  };
496
425
  }
497
426
  const config = {
498
- // root: ssr === 'fastify' ? appDir.pathname : frameworkDir.pathname,
499
427
  root: appDir.pathname,
500
428
  publicDir: publicDir.pathname,
501
429
  base,
@@ -523,33 +451,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
523
451
  ssr: ssr === 'server' || ssr === 'fastify' ? true : false,
524
452
  ssrManifest: ssr === 'client' || ssr === 'ssg',
525
453
  rollupOptions
526
- // ssr === 'server'
527
- // ? {
528
- // input: [
529
- // new URL('ssr/entry-server.ts', frameworkDir).pathname,
530
- // new URL('ssr/prerender.ts', frameworkDir).pathname,
531
- // new URL('ssr/server.ts', frameworkDir).pathname
532
- // ],
533
- // output: {
534
- // minifyInternalExports: false,
535
- // entryFileNames: '[name].mjs',
536
- // chunkFileNames: '[name].mjs',
537
- // format: 'es',
538
- // manualChunks: (id) => {
539
- // if (id.includes('vitrify/src/vite/')) {
540
- // const name = id.split('/').at(-1)?.split('.').at(0)
541
- // if (name && manualChunks.includes(name)) return name
542
- // } else if (id.includes('node_modules')) {
543
- // return 'vendor'
544
- // }
545
- // }
546
- // }
547
- // }
548
- // : {
549
- // output: {
550
- // format: 'es'
551
- // }
552
- // }
553
454
  },
554
455
  ssr: {
555
456
  // Create a SSR bundle
@@ -79,7 +79,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
79
79
  const directives = await import('virtual:quasar-directives');
80
80
  // @ts-ignore
81
81
  const { default: lang } = await import('virtual:quasar-lang');
82
- console.log(lang);
83
82
  app.use(staticImports?.Quasar, {
84
83
  plugins: quasarPlugins,
85
84
  directives,
@@ -1,6 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  import type { LogLevel, InlineConfig } from 'vite';
3
- import { ViteDevServer } from 'vite';
4
3
  import type { Server } from 'net';
5
4
  export declare function createVitrifyDevServer({ port, logLevel, ssr, framework, host, appDir, publicDir, base }: {
6
5
  port?: number;
@@ -11,7 +10,7 @@ export declare function createVitrifyDevServer({ port, logLevel, ssr, framework,
11
10
  appDir?: URL;
12
11
  publicDir?: URL;
13
12
  base?: string;
14
- }): Promise<ViteDevServer>;
13
+ }): Promise<import("vite").ViteDevServer>;
15
14
  export declare function createServer({ port, logLevel, ssr, framework, host, appDir, publicDir }: {
16
15
  port?: number;
17
16
  logLevel?: LogLevel;
@@ -42,7 +41,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
42
41
  server: import("vite").ResolvedServerOptions;
43
42
  build: Required<import("vite").BuildOptions>;
44
43
  preview: import("vite").ResolvedPreviewOptions;
45
- ssr: import("vite").ResolvedSSROptions | undefined;
44
+ ssr: import("vite").ResolvedSSROptions;
46
45
  assetsInclude: (file: string) => boolean;
47
46
  logger: import("vite").Logger;
48
47
  createResolver: (options?: Partial<import("vite").InternalResolveOptions> | undefined) => import("vite").ResolveFn;
@@ -1,6 +1,7 @@
1
1
  import type { Alias, UserConfig } from 'vite';
2
2
  import type { QuasarConf } from './plugins/quasar.js';
3
3
  import type { ComponentInternalInstance } from '@vue/runtime-core';
4
+ import type { FastifyServerOptions } from 'fastify';
4
5
  export declare type BootFunction = ({ app, ssrContext, staticImports }: {
5
6
  app: any;
6
7
  ssrContext: Record<string, unknown>;
@@ -72,6 +73,7 @@ export interface VitrifyConfig extends UserConfig {
72
73
  */
73
74
  ssr?: {
74
75
  serverModules?: string[];
76
+ fastify?: FastifyServerOptions;
75
77
  };
76
78
  /**
77
79
  * Development only configuration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.6.18",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Pre-configured Vite CLI for your framework",
@@ -57,47 +57,47 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@fastify/middie": "^8.0.0",
60
- "@fastify/static": "^6.4.0",
61
- "@quasar/extras": "^1.14.2",
62
- "@vitejs/plugin-vue": "^3.0.0-alpha.1",
60
+ "@fastify/static": "^6.5.0",
61
+ "@quasar/extras": "^1.15.1",
62
+ "@vitejs/plugin-vue": "^3.0.1",
63
63
  "builtin-modules": "^3.3.0",
64
64
  "cac": "^6.7.12",
65
65
  "chalk": "^5.0.1",
66
66
  "critters": "^0.0.16",
67
67
  "cross-env": "^7.0.3",
68
- "esbuild": "^0.14.48",
69
- "fastify": "^4.2.0",
68
+ "esbuild": "^0.14.51",
69
+ "fastify": "^4.3.0",
70
70
  "glob": "^8.0.3",
71
- "happy-dom": "^6.0.0",
71
+ "happy-dom": "^6.0.4",
72
72
  "magic-string": "^0.26.2",
73
73
  "merge-deep": "^3.0.3",
74
74
  "readline": "^1.3.0",
75
- "rollup-plugin-visualizer": "^5.6.0",
76
- "sass": "1.53.0",
77
- "ts-node": "^10.8.2",
78
- "unplugin-vue-components": "^0.21.0",
79
- "vite": "3.0.0-beta.6",
80
- "vitest": "^0.17.0"
75
+ "rollup-plugin-visualizer": "^5.7.1",
76
+ "sass": "1.54.0",
77
+ "ts-node": "^10.9.1",
78
+ "unplugin-vue-components": "^0.21.2",
79
+ "vite": "^3.0.4",
80
+ "vitest": "^0.20.2"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@types/connect": "^3.4.35",
84
84
  "@types/glob": "^7.2.0",
85
85
  "@types/merge-deep": "^3.0.0",
86
- "@types/node": "^18.0.1",
86
+ "@types/node": "^18.6.3",
87
87
  "@types/ws": "^8.5.3",
88
88
  "@vue/runtime-core": "^3.2.37",
89
- "quasar": "^2.7.5",
90
- "rollup": "^2.75.7",
89
+ "quasar": "^2.7.6",
90
+ "rollup": "^2.77.2",
91
91
  "typescript": "^4.7.4",
92
92
  "vue": "^3.2.37",
93
- "vue-router": "^4.1.0"
93
+ "vue-router": "^4.1.3"
94
94
  },
95
95
  "peerDependencies": {
96
- "@fastify/static": "^6.4.0",
97
- "fastify": "^4.2.0",
98
- "quasar": "^2.7.5",
96
+ "@fastify/static": "^6.5.0",
97
+ "fastify": "^4.3.0",
98
+ "quasar": "^2.7.6",
99
99
  "vue": "^3.2.37",
100
- "vue-router": "^4.1.0"
100
+ "vue-router": "^4.1.3"
101
101
  },
102
102
  "publishConfig": {
103
103
  "access": "public",
@@ -1,13 +1,11 @@
1
1
  import type { LogLevel, InlineConfig } from 'vite'
2
- import { ViteDevServer, mergeConfig } from 'vite'
3
2
  import { searchForWorkspaceRoot } from 'vite'
4
3
  import { baseConfig } from '../index.js'
5
4
  import type { Server } from 'net'
6
- import type { FastifyInstance } from 'fastify/types/instance'
7
5
  import fastify from 'fastify'
6
+ import type { FastifyServerOptions } from 'fastify'
8
7
  import { fastifySsrPlugin } from '../frameworks/vue/fastify-ssr-plugin.js'
9
- import type { ServerOptions } from 'https'
10
- import type { OnRenderedHook } from '../vitrify-config.js'
8
+ import type { OnRenderedHook, VitrifyConfig } from '../vitrify-config.js'
11
9
 
12
10
  export async function createVitrifyDevServer({
13
11
  port = 3000,
@@ -130,6 +128,7 @@ export async function createServer({
130
128
  let setup
131
129
  let server: Server
132
130
  let onRendered: OnRenderedHook[]
131
+ let vitrifyConfig: VitrifyConfig
133
132
 
134
133
  console.log(`Development mode: ${ssr ? ssr : 'csr'}`)
135
134
  if (ssr) {
@@ -138,11 +137,13 @@ export async function createServer({
138
137
  ? new URL('src/vite/fastify/entry.ts', cliDir).pathname
139
138
  : new URL(`src/vite/${framework}/ssr/app.ts`, cliDir).pathname
140
139
 
141
- ;({ setup, onRendered } = await vite.ssrLoadModule(entryUrl))
140
+ ;({ setup, onRendered, vitrifyConfig } = await vite.ssrLoadModule(entryUrl))
141
+ console.log(vitrifyConfig)
142
142
  const app = fastify({
143
143
  logger: false,
144
- https: vite.config.server.https as ServerOptions
145
- })
144
+ https: vite.config.server.https,
145
+ ...vitrifyConfig.vitrify?.ssr?.fastify
146
+ } as FastifyServerOptions)
146
147
  if (process.env) process.env.MODE = 'development'
147
148
  if (setup) {
148
149
  await setup({
package/src/node/index.ts CHANGED
@@ -21,7 +21,7 @@ import type {
21
21
  } from './vitrify-config.js'
22
22
  import type { VitrifyContext } from './bin/run.js'
23
23
  import type { VitrifyPlugin } from './plugins/index.js'
24
- import { getPkgJsonDir, resolve } from './app-urls.js'
24
+ import { resolve } from './app-urls.js'
25
25
  import type { ManualChunksOption, RollupOptions } from 'rollup'
26
26
 
27
27
  const internalServerModules = [
@@ -237,13 +237,6 @@ export const baseConfig = async ({
237
237
  console.error('package.json not found')
238
238
  }
239
239
 
240
- const ssrTransformCustomDir = () => {
241
- return {
242
- props: [],
243
- needRuntime: true
244
- }
245
- }
246
-
247
240
  const frameworkPlugins = []
248
241
  for (const framework of Object.keys(configPluginMap)) {
249
242
  if (Object.keys(vitrifyConfig).includes(framework)) {
@@ -275,27 +268,7 @@ export const baseConfig = async ({
275
268
  ]
276
269
 
277
270
  const plugins: UserConfig['plugins'] = [
278
- vuePlugin({
279
- // compiler: await import('vue/compiler-sfc'),
280
- // template: {
281
- // ssr: !!ssr,
282
- // compilerOptions: {
283
- // directiveTransforms: {
284
- // 'close-popup': ssrTransformCustomDir,
285
- // intersection: ssrTransformCustomDir,
286
- // ripple: ssrTransformCustomDir,
287
- // mutation: ssrTransformCustomDir,
288
- // morph: ssrTransformCustomDir,
289
- // scroll: ssrTransformCustomDir,
290
- // 'scroll-fire': ssrTransformCustomDir,
291
- // 'touch-hold': ssrTransformCustomDir,
292
- // 'touch-pan': ssrTransformCustomDir,
293
- // 'touch-repeat': ssrTransformCustomDir,
294
- // 'touch-swipe': ssrTransformCustomDir
295
- // }
296
- // }
297
- // }
298
- }),
271
+ vuePlugin(),
299
272
  ...frameworkPlugins,
300
273
  {
301
274
  name: 'vitrify-setup',
@@ -311,21 +284,7 @@ export const baseConfig = async ({
311
284
  globalSass = config.vitrify?.sass?.global || []
312
285
  additionalData = config.vitrify?.sass?.additionalData || []
313
286
 
314
- return {
315
- // css: {
316
- // preprocessorOptions: {
317
- // sass: {
318
- // additionalData: [
319
- // ...Object.entries(sassVariables).map(
320
- // ([key, value]) => `${key}: ${value}`
321
- // )
322
- // // ...additionalData
323
- // // config.css?.preprocessorOptions?.sass.additionalData
324
- // ].join('\n')
325
- // }
326
- // }
327
- // }
328
- }
287
+ return {}
329
288
  },
330
289
  configureServer(server) {
331
290
  server.middlewares.use('/', (req, res, next) => {
@@ -363,30 +322,20 @@ export const baseConfig = async ({
363
322
  .join(', ')}]
364
323
  export const onSetup = []
365
324
  ${onSetupFiles
366
- .map(
367
- (url, index) =>
368
- `import ${url.pathname
369
- .replaceAll('/', '')
370
- .replaceAll('.', '')} from '${
371
- url.pathname
372
- }'; onSetup.push(${url.pathname
373
- .replaceAll('/', '')
374
- .replaceAll('.', '')})`
375
- )
325
+ .map((url, index) => {
326
+ const varName = url.pathname
327
+ .replaceAll('/', '')
328
+ .replaceAll('.', '')
329
+ .replaceAll('-', '')
330
+ return `import ${varName} from '${url.pathname}'; onSetup.push(${varName})`
331
+ })
376
332
  .join('\n')}`
377
- // export const onSetup = [${onSetupHooks
378
- // .map((fn) => `${String(fn)}`)
379
- // .join(', ')}]`
380
- /**
381
- * CSS imports in virtual files do not seem to work. Using transform() instead
382
- */
383
- // } else if (id === 'virtual:global-css') {
384
- // return `${globalCss.map((css) => `import '${css}'`).join('\n')}`
385
333
  } else if (id === 'virtual:static-imports') {
386
334
  return `${Object.entries(staticImports)
387
- .map(
388
- ([key, value]) => `export { ${value.join(',')} } from '${key}';`
389
- )
335
+ .map(([key, value]) => {
336
+ const deduped = [...new Set(value)]
337
+ return `export { ${deduped.join(',')} } from '${key}';`
338
+ })
390
339
  .join('\n')}`
391
340
  } else if (id === 'vitrify.sass') {
392
341
  return [
@@ -408,16 +357,16 @@ export const baseConfig = async ({
408
357
  plugins.unshift({
409
358
  name: 'html-transform',
410
359
  enforce: 'pre',
411
- transform: (code, id) => {
412
- if (id.endsWith('App.vue')) {
413
- code =
414
- code +
415
- `<style lang="sass">
416
- // do not remove, required for additionalData import
417
- </style>`
418
- }
419
- return code
420
- },
360
+ // transform: (code, id) => {
361
+ // if (id.endsWith('App.vue')) {
362
+ // code =
363
+ // code +
364
+ // `<style lang="sass">
365
+ // // do not remove, required for additionalData import
366
+ // </style>`
367
+ // }
368
+ // return code
369
+ // },
421
370
  transformIndexHtml: {
422
371
  enforce: 'pre',
423
372
  transform: (html) => {
@@ -479,10 +428,6 @@ export const baseConfig = async ({
479
428
  packageUrls['vue']
480
429
  ).pathname
481
430
  },
482
- // {
483
- // find: new RegExp('^vue/server-renderer$'),
484
- // replacement: 'vue/server-renderer/index.mjs'
485
- // },
486
431
  {
487
432
  find: new RegExp('^vue-router$'),
488
433
  replacement: new URL(
@@ -490,9 +435,6 @@ export const baseConfig = async ({
490
435
  packageUrls['vue-router']
491
436
  ).pathname
492
437
  }
493
- // { find: 'vue', replacement: packageUrls['vue'].pathname },
494
- // { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
495
- // { find: 'vitrify', replacement: cliDir.pathname }
496
438
  ]
497
439
  if (mode === 'development' && vitrifyConfig.vitrify?.dev?.alias)
498
440
  alias.push(...vitrifyConfig.vitrify.dev.alias)
@@ -519,25 +461,16 @@ export const baseConfig = async ({
519
461
  ],
520
462
  external,
521
463
  output: {
522
- minifyInternalExports: !debug,
464
+ minifyInternalExports: false,
523
465
  entryFileNames: '[name].mjs',
524
466
  chunkFileNames: '[name].mjs',
525
467
  format: 'es',
526
468
  manualChunks
527
- // manualChunks: (id) => {
528
- // if (id.includes('vitrify/src/vite/')) {
529
- // const name = id.split('/').at(-1)?.split('.').at(0)
530
- // if (name && manualChunks.includes(name)) return name
531
- // } else if (id.includes('node_modules')) {
532
- // return 'vendor'
533
- // }
534
- // }
535
469
  }
536
470
  }
537
471
  // Create a SSR bundle
538
472
  noExternal = [
539
473
  new RegExp(`^(?!(${[...builtinModules, ...serverModules].join('|')}))`)
540
- // new RegExp(`^(?!.*(${[...builtinModules, ...serverModules].join('|')}))`)
541
474
  ]
542
475
  } else if (ssr === 'fastify') {
543
476
  rollupOptions = {
@@ -550,14 +483,6 @@ export const baseConfig = async ({
550
483
  chunkFileNames: '[name].mjs',
551
484
  format: 'es',
552
485
  manualChunks
553
- // manualChunks: (id) => {
554
- // if (id.includes('vitrify/src/vite/')) {
555
- // const name = id.split('/').at(-1)?.split('.').at(0)
556
- // if (name && manualChunks.includes(name)) return name
557
- // } else if (id.includes('node_modules')) {
558
- // return 'vendor'
559
- // }
560
- // }
561
486
  }
562
487
  }
563
488
  // Create a SSR bundle
@@ -567,13 +492,9 @@ export const baseConfig = async ({
567
492
  } else {
568
493
  rollupOptions = {
569
494
  ...rollupOptions,
570
- // input: [
571
- // new URL('index.html', frameworkDir).pathname
572
- // // new URL('csr/server.ts', frameworkDir).pathname
573
- // ],
574
495
  external,
575
496
  output: {
576
- minifyInternalExports: !debug,
497
+ minifyInternalExports: false,
577
498
  entryFileNames: '[name].mjs',
578
499
  chunkFileNames: '[name].mjs',
579
500
  format: 'es',
@@ -583,7 +504,6 @@ export const baseConfig = async ({
583
504
  }
584
505
 
585
506
  const config = {
586
- // root: ssr === 'fastify' ? appDir.pathname : frameworkDir.pathname,
587
507
  root: appDir.pathname,
588
508
  publicDir: publicDir.pathname,
589
509
  base,
@@ -611,33 +531,6 @@ export const baseConfig = async ({
611
531
  ssr: ssr === 'server' || ssr === 'fastify' ? true : false,
612
532
  ssrManifest: ssr === 'client' || ssr === 'ssg',
613
533
  rollupOptions
614
- // ssr === 'server'
615
- // ? {
616
- // input: [
617
- // new URL('ssr/entry-server.ts', frameworkDir).pathname,
618
- // new URL('ssr/prerender.ts', frameworkDir).pathname,
619
- // new URL('ssr/server.ts', frameworkDir).pathname
620
- // ],
621
- // output: {
622
- // minifyInternalExports: false,
623
- // entryFileNames: '[name].mjs',
624
- // chunkFileNames: '[name].mjs',
625
- // format: 'es',
626
- // manualChunks: (id) => {
627
- // if (id.includes('vitrify/src/vite/')) {
628
- // const name = id.split('/').at(-1)?.split('.').at(0)
629
- // if (name && manualChunks.includes(name)) return name
630
- // } else if (id.includes('node_modules')) {
631
- // return 'vendor'
632
- // }
633
- // }
634
- // }
635
- // }
636
- // : {
637
- // output: {
638
- // format: 'es'
639
- // }
640
- // }
641
534
  },
642
535
  ssr: {
643
536
  // Create a SSR bundle
@@ -152,7 +152,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
152
152
  const directives = await import('virtual:quasar-directives')
153
153
  // @ts-ignore
154
154
  const { default: lang } = await import('virtual:quasar-lang')
155
- console.log(lang)
155
+
156
156
  app.use(
157
157
  staticImports?.Quasar,
158
158
  {
@@ -1,6 +1,7 @@
1
1
  import type { Alias, UserConfig } from 'vite'
2
2
  import type { QuasarConf } from './plugins/quasar.js'
3
3
  import type { ComponentInternalInstance } from '@vue/runtime-core'
4
+ import type { FastifyServerOptions } from 'fastify'
4
5
 
5
6
  export type BootFunction = ({
6
7
  app,
@@ -93,6 +94,7 @@ export interface VitrifyConfig extends UserConfig {
93
94
  */
94
95
  ssr?: {
95
96
  serverModules?: string[]
97
+ fastify?: FastifyServerOptions
96
98
  }
97
99
  /**
98
100
  * Development only configuration
@@ -1,5 +1,6 @@
1
1
  import type { FastifyInstance } from 'fastify'
2
2
  import { onSetup } from 'virtual:vitrify-hooks'
3
+ export { default as vitrifyConfig } from 'virtual:vitrify-config'
3
4
 
4
5
  export const setup = async ({ fastify }: { fastify: FastifyInstance }) => {
5
6
  if (onSetup?.length) {
@@ -1,8 +1,9 @@
1
1
  import Fastify from 'fastify'
2
- import { setup } from './entry'
2
+ import { setup, vitrifyConfig } from './entry'
3
3
 
4
4
  const fastify = Fastify({
5
- logger: true
5
+ logger: true,
6
+ ...vitrifyConfig.vitrify?.ssr.fastify
6
7
  })
7
8
  await setup({ fastify })
8
9