vitrify 0.20.0 → 0.22.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.
@@ -0,0 +1,227 @@
1
+ import { fileURLToPath } from 'url';
2
+ import { findDepPkgJsonPath } from 'vitefu';
3
+ import { QuasarResolver } from 'unplugin-vue-components/resolvers';
4
+ export const injectSsrContext = (html, ssrContext) => html
5
+ .replace(/(<html[^>]*)(>)/i, (found, start, end) => {
6
+ let matches;
7
+ matches = found.match(/\sdir\s*=\s*['"]([^'"]*)['"]/i);
8
+ if (matches) {
9
+ start = start.replace(matches[0], '');
10
+ }
11
+ matches = found.match(/\slang\s*=\s*['"]([^'"]*)['"]/i);
12
+ if (matches) {
13
+ start = start.replace(matches[0], '');
14
+ }
15
+ return `${start} ${ssrContext._meta.htmlAttrs || ''} ${end}`;
16
+ })
17
+ .replace(/(<head[^>]*)(>)/i, (_, start, end) => `${start}${end}${ssrContext._meta.headTags || ''}`)
18
+ .replace(/(<\/head>)/i, (_, tag) => `${ssrContext._meta.resourceStyles || ''}${ssrContext._meta.endingHeadTags || ''}${tag}`)
19
+ .replace(/(<body[^>]*)(>)/i, (found, start, end) => {
20
+ let classes = ssrContext._meta.bodyClasses || '';
21
+ const matches = found.match(/\sclass\s*=\s*['"]([^'"]*)['"]/i);
22
+ if (matches) {
23
+ if (matches[1].length > 0) {
24
+ classes += ` ${matches[1]}`;
25
+ }
26
+ start = start.replace(matches[0], '');
27
+ }
28
+ return `${start} class="${classes.trim()}" ${ssrContext._meta.bodyAttrs || ''}${end}${ssrContext._meta.bodyTags || ''}`;
29
+ });
30
+ export const QuasarPlugin = async ({ ssr = false, pwa = false, options }) => {
31
+ let plugins = [];
32
+ const quasarConf = options;
33
+ return {
34
+ plugins: [
35
+ {
36
+ name: 'vite-plugin-quasar-transform',
37
+ enforce: 'pre',
38
+ transform: (code, id, options) => {
39
+ code = code
40
+ .replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
41
+ .replaceAll('__QUASAR_SSR_SERVER__', ssr ? '(import.meta.env.SSR === true)' : 'false')
42
+ .replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '(import.meta.env.SSR === false)' : 'false')
43
+ .replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '(import.meta.env.SSR === false)' : 'false');
44
+ return code;
45
+ }
46
+ },
47
+ {
48
+ name: 'vite-plugin-quasar-setup',
49
+ enforce: 'pre',
50
+ config: async (config, env) => {
51
+ const { vitrify: { urls } = {} } = config;
52
+ // if (quasar) quasarConf = quasar
53
+ if (!quasarConf.framework.lang && config.vitrify?.lang)
54
+ quasarConf.framework.lang = config.vitrify.lang;
55
+ const globalCss = quasarConf?.extras?.map((extra) => `@quasar/extras/${extra}/${extra}.css`);
56
+ const localPackages = ['@quasar/extras', 'quasar'];
57
+ // const localPackages: string[] = []
58
+ await (async () => {
59
+ for (const val of localPackages) {
60
+ const pkgDir = await findDepPkgJsonPath(val, fileURLToPath(config.vitrify.urls.app));
61
+ if (pkgDir)
62
+ urls.packages[val] = new URL(`file://${pkgDir}`);
63
+ }
64
+ })();
65
+ const onMountedHooks = [
66
+ async (instance) => {
67
+ const { proxy: { $q } } = instance;
68
+ if ($q.onSSRHydrated !== void 0)
69
+ $q.onSSRHydrated();
70
+ }
71
+ ];
72
+ const onBootHooks = [
73
+ async ({ app, ssrContext, staticImports }) => {
74
+ // @ts-expect-error undefined
75
+ const quasarPlugins = await import('virtual:quasar-plugins');
76
+ // @ts-expect-error undefined
77
+ const directives = await import('virtual:quasar-directives');
78
+ // @ts-expect-error undefined
79
+ const { default: lang } = await import('virtual:quasar-lang');
80
+ const { default: iconSet } = await import(
81
+ // @ts-expect-error undefined
82
+ 'virtual:quasar-iconSet');
83
+ const { default: iconMapFn } = await import(
84
+ // @ts-expect-error undefined
85
+ 'virtual:quasar-iconMapFn');
86
+ app.use(staticImports?.Quasar, {
87
+ plugins: quasarPlugins,
88
+ directives,
89
+ lang,
90
+ iconSet,
91
+ config: {
92
+ iconMapFn
93
+ }
94
+ }, ssrContext);
95
+ }
96
+ ];
97
+ /**
98
+ * Importing package.json is problematic
99
+ */
100
+ const version = '?';
101
+ /**
102
+ * All components should have been auto-imported
103
+ */
104
+ if (quasarConf?.framework?.plugins) {
105
+ if (!quasarConf.framework)
106
+ quasarConf.framework = {};
107
+ quasarConf.framework.plugins = [
108
+ ...new Set(quasarConf.framework.plugins)
109
+ ];
110
+ plugins = quasarConf?.framework.plugins;
111
+ }
112
+ return {
113
+ vitrify: {
114
+ urls,
115
+ globalCss,
116
+ staticImports: {
117
+ quasar: ['Quasar']
118
+ },
119
+ hooks: {
120
+ onBoot: onBootHooks,
121
+ onMounted: onMountedHooks,
122
+ onRendered: [injectSsrContext]
123
+ },
124
+ sass: quasarConf.disableSass
125
+ ? undefined
126
+ : {
127
+ global: ['quasar/src/css/index.sass']
128
+ }
129
+ },
130
+ resolve: {
131
+ alias: [
132
+ {
133
+ find: 'quasar/src/',
134
+ replacement: fileURLToPath(new URL('./src/', config.vitrify.urls.packages.quasar))
135
+ }
136
+ ]
137
+ },
138
+ optimizeDeps: {
139
+ exclude: ['quasar']
140
+ },
141
+ define: {
142
+ __DEV__: process.env.NODE_ENV !== 'production' || true,
143
+ __QUASAR_VERSION__: `'${version}'`
144
+ },
145
+ ssr: {
146
+ noExternal: ['quasar']
147
+ }
148
+ };
149
+ }
150
+ },
151
+ {
152
+ name: 'quasar-virtual-modules',
153
+ enforce: 'pre',
154
+ config: async (config, env) => ({
155
+ resolve: {
156
+ alias: [
157
+ {
158
+ find: new RegExp('^quasar$'),
159
+ replacement: 'virtual:quasar'
160
+ }
161
+ // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
162
+ ]
163
+ }
164
+ }),
165
+ resolveId(id) {
166
+ switch (id) {
167
+ case 'virtual:quasar-plugins':
168
+ return 'virtual:quasar-plugins';
169
+ case 'virtual:quasar-directives':
170
+ return 'virtual:quasar-directives';
171
+ case 'virtual:quasar-lang':
172
+ return 'virtual:quasar-lang';
173
+ case 'virtual:quasar-iconSet':
174
+ return 'virtual:quasar-iconSet';
175
+ case 'virtual:quasar-iconMapFn':
176
+ return 'virtual:quasar-iconMapFn';
177
+ case 'virtual:quasar':
178
+ return { id: 'virtual:quasar', moduleSideEffects: false };
179
+ default:
180
+ return;
181
+ }
182
+ },
183
+ load(id) {
184
+ if (id === 'virtual:quasar-plugins') {
185
+ return `export { ${plugins.join(',')} } from 'quasar'`;
186
+ }
187
+ else if (id === 'virtual:quasar-directives') {
188
+ return `export * from 'quasar/src/directives.js'`;
189
+ }
190
+ else if (id === 'virtual:quasar-lang') {
191
+ return `import lang from 'quasar/lang/${quasarConf?.framework?.lang || 'en-US'}';
192
+ export default lang`;
193
+ }
194
+ else if (id === 'virtual:quasar-iconSet') {
195
+ return `${typeof quasarConf.framework.iconSet === 'string'
196
+ ? `import iconSet from 'quasar/icon-set/${quasarConf?.framework.iconSet || 'material-icons'}';
197
+ export default iconSet`
198
+ : `export default ${quasarConf.framework.iconSet
199
+ ? JSON.stringify(quasarConf.framework.iconSet)
200
+ : null}`}`;
201
+ }
202
+ else if (id === 'virtual:quasar-iconMapFn') {
203
+ return `export default ${quasarConf?.framework.iconMapFn?.toString() ?? null}`;
204
+ }
205
+ else if (id === 'virtual:quasar') {
206
+ return `export * from 'quasar/src/plugins.js';
207
+ export * from 'quasar/src/components.js';
208
+ export * from 'quasar/src/composables.js';
209
+ export * from 'quasar/src/directives.js';
210
+ export * from 'quasar/src/utils.js';
211
+ export * from 'quasar/src/composables.js';
212
+ export { default as Quasar } from 'quasar/src/install-quasar.js'`;
213
+ }
214
+ return null;
215
+ }
216
+ }
217
+ ],
218
+ config: {
219
+ vitrify: {
220
+ unpluginVueComponents: {
221
+ resolvers: [QuasarResolver()]
222
+ }
223
+ }
224
+ }
225
+ };
226
+ };
227
+ export default QuasarPlugin;
@@ -1,6 +1,6 @@
1
1
  export declare const resolve: (packageName: string, base: URL, counter?: number) => URL;
2
2
  export declare const getPkgJsonDir: (dir: URL) => URL;
3
- export declare const getAppDir: () => URL;
3
+ export declare const getAppDir: (dir?: URL) => URL;
4
4
  export declare const getCliDir: () => URL;
5
5
  export declare const getCliViteDir: (cliDir: URL) => URL;
6
6
  export declare const getSrcDir: (appDir: URL) => URL;
@@ -29,5 +29,15 @@ declare const renderHtml: (options: {
29
29
  manifest: Record<string, unknown>;
30
30
  render: any;
31
31
  }) => Promise<string>;
32
- export { fastifySsrPlugin, renderHtml };
32
+ declare const loadSSRAssets: ({ mode, distDir }?: {
33
+ mode?: "ssr" | "ssg";
34
+ distDir?: URL;
35
+ }) => Promise<{
36
+ template: string;
37
+ manifest: any;
38
+ render: any;
39
+ getRoutes: any;
40
+ onRendered: any;
41
+ }>;
42
+ export { fastifySsrPlugin, renderHtml, loadSSRAssets };
33
43
  export type FastifySsrPlugin = typeof fastifySsrPlugin;
@@ -1,8 +1,10 @@
1
1
  import type { OnRenderedHook } from 'src/node/vitrify-config.js';
2
- export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath, onRendered }: {
2
+ import { type RouteRecordRaw } from 'vue-router';
3
+ export declare const prerender: ({ outDir, template, manifest, render, routes, onRendered }: {
3
4
  outDir: string;
4
- templatePath: string;
5
- manifestPath: string;
6
- entryServerPath: string;
5
+ template: string;
6
+ manifest: Record<string, unknown>;
7
+ render: unknown;
8
+ routes: RouteRecordRaw[];
7
9
  onRendered: OnRenderedHook[];
8
10
  }) => Promise<void[]>;
@@ -1,7 +1,17 @@
1
1
  import type { Plugin } from 'vite';
2
- export type VitrifyPlugin = ({ ssr, mode, command }: {
2
+ import { VitrifyConfig } from '../vitrify-config.js';
3
+ type VitrifyPluginReturnType = {
4
+ plugin: Plugin;
5
+ config?: Partial<VitrifyConfig>;
6
+ } | {
7
+ plugins: Plugin[];
8
+ config?: Partial<VitrifyConfig>;
9
+ };
10
+ export type VitrifyPlugin<Options> = ({ ssr, pwa, mode, command, options }: {
3
11
  ssr?: 'server' | 'client' | 'ssg' | 'fastify' | false;
4
12
  pwa?: boolean;
5
13
  mode?: 'production' | 'development';
6
14
  command?: 'build' | 'dev' | 'test';
7
- }) => Promise<Plugin | Plugin[]> | Plugin | Plugin[];
15
+ options: Options;
16
+ }) => Promise<VitrifyPluginReturnType> | VitrifyPluginReturnType;
17
+ export * from './quasar/index.js';
@@ -1,6 +1,6 @@
1
- import type { VitrifyPlugin } from './index.js';
1
+ import type { VitrifyPlugin } from '../index.js';
2
2
  import { type QuasarFonts, type QuasarComponents, type QuasarDirectives, type QuasarIconSets, type QuasarPlugins, type GlobalQuasarIconMapFn, type QuasarIconSet } from 'quasar';
3
- export interface QuasarConf {
3
+ export interface QuasarPluginOptions {
4
4
  framework: {
5
5
  components?: (keyof QuasarComponents)[];
6
6
  directives?: (keyof QuasarDirectives)[];
@@ -13,5 +13,5 @@ export interface QuasarConf {
13
13
  disableSass?: boolean;
14
14
  }
15
15
  export declare const injectSsrContext: (html: string, ssrContext: Record<string, any>) => string;
16
- export declare const QuasarPlugin: VitrifyPlugin;
16
+ export declare const QuasarPlugin: VitrifyPlugin<QuasarPluginOptions>;
17
17
  export default QuasarPlugin;
@@ -1,9 +1,10 @@
1
1
  import type { Alias, UserConfig as ViteUserConfig, ViteDevServer } from 'vite';
2
- import type { QuasarConf } from './plugins/quasar.js';
3
2
  import type { ComponentInternalInstance } from '@vue/runtime-core';
4
3
  import type { FastifyInstance, FastifyServerOptions } from 'fastify';
5
4
  import type { VitePWAOptions } from 'vite-plugin-pwa';
5
+ import type { Options as unpluginVueComponentsOptions } from 'unplugin-vue-components';
6
6
  import type { UserConfig as UnoCSSUserConfig } from '@unocss/core';
7
+ import { VitrifyPlugin } from './plugins/index.js';
7
8
  export type BootFunction = ({ app, ssrContext, staticImports }: {
8
9
  app: any;
9
10
  ssrContext: Record<string, unknown>;
@@ -25,6 +26,10 @@ export type OnSetupFile = URL;
25
26
  export interface VitrifyConfig extends ViteUserConfig {
26
27
  vitrify?: {
27
28
  lang?: string;
29
+ /**
30
+ * Vitrify plugins
31
+ */
32
+ plugins?: VitrifyPluginConfig[];
28
33
  /**
29
34
  * Global CSS imports
30
35
  */
@@ -97,8 +102,11 @@ export interface VitrifyConfig extends ViteUserConfig {
97
102
  * UnoCSS Configuration
98
103
  */
99
104
  unocss?: UnoCSSUserConfig;
105
+ /**
106
+ * unplugin-vue-components configuration
107
+ */
108
+ unpluginVueComponents?: unpluginVueComponentsOptions;
100
109
  };
101
- quasar?: QuasarConf;
102
110
  }
103
111
  export type VitrifyCommands = 'build' | 'dev' | 'test';
104
112
  export type VitrifyModes = 'production' | 'development';
@@ -108,4 +116,9 @@ export type VitrifyConfigAsync = ({ mode, command }: {
108
116
  mode: VitrifyModes;
109
117
  command: VitrifyCommands;
110
118
  }) => Promise<VitrifyConfig>;
119
+ type VitrifyPluginConfig = {
120
+ plugin: VitrifyPlugin<any>;
121
+ options: any;
122
+ };
111
123
  export declare const defineConfig: (config: VitrifyConfig) => VitrifyConfig;
124
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Vite as your Full Stack development tool",
@@ -30,9 +30,9 @@
30
30
  "./client": {
31
31
  "types": "./client.d.ts"
32
32
  },
33
- "./unocss/quasar/styles": {
34
- "types": "./dist/types/plugins/quasar/unocss/styles/index.d.ts",
35
- "import": "./dist/plugins/quasar/unocss/styles/index.js"
33
+ "./plugins": {
34
+ "types": "./dist/types/plugins/index.d.ts",
35
+ "import": "./dist/plugins/index.js"
36
36
  }
37
37
  },
38
38
  "engines": {
@@ -49,10 +49,11 @@
49
49
  "homepage": "https://github.com/simsustech/vitrify/tree/main/#readme",
50
50
  "dependencies": {
51
51
  "@fastify/middie": "^9.0.3",
52
+ "@fastify/one-line-logger": "^2.0.2",
52
53
  "@fastify/static": "^8.1.1",
53
54
  "@unocss/core": "^66.0.0",
54
55
  "@unocss/preset-uno": "^66.0.0",
55
- "@unocss/preset-web-fonts": "66.1.0-beta.10",
56
+ "@unocss/preset-web-fonts": "66.1.0-beta.13",
56
57
  "@unocss/preset-wind": "^66.0.0",
57
58
  "@vitejs/plugin-vue": "^5.2.3",
58
59
  "ajv": "^8.17.1",
@@ -60,23 +61,23 @@
60
61
  "cac": "^6.7.14",
61
62
  "chalk": "^5.4.1",
62
63
  "cross-env": "^7.0.3",
63
- "esbuild": "^0.25.2",
64
- "fastify": "^5.2.2",
65
- "glob": "^11.0.1",
66
- "happy-dom": "^17.4.4",
64
+ "esbuild": "^0.25.3",
65
+ "fastify": "^5.3.2",
66
+ "glob": "^11.0.2",
67
+ "happy-dom": "^17.4.6",
67
68
  "is-port-reachable": "^4.0.0",
68
69
  "magic-string": "^0.30.17",
69
70
  "merge-deep": "^3.0.3",
70
71
  "readline": "^1.3.0",
71
72
  "rollup-plugin-visualizer": "^5.14.0",
72
- "sass": "1.86.3",
73
+ "sass": "1.87.0",
73
74
  "ts-node": "^10.9.2",
74
75
  "unocss": "^66.0.0",
75
- "unplugin-vue-components": "^28.4.1",
76
- "vite": "^6.2.5",
76
+ "unplugin-vue-components": "^28.5.0",
77
+ "vite": "^6.3.4",
77
78
  "vite-plugin-pwa": "^1.0.0",
78
79
  "vitefu": "^1.0.6",
79
- "vitest": "^3.1.1",
80
+ "vitest": "^3.1.2",
80
81
  "workbox-window": "^7.3.0"
81
82
  },
82
83
  "devDependencies": {
@@ -87,25 +88,25 @@
87
88
  "@types/connect": "^3.4.38",
88
89
  "@types/glob": "^8.1.0",
89
90
  "@types/merge-deep": "^3.0.3",
90
- "@types/node": "^22.14.0",
91
+ "@types/node": "^22.15.3",
91
92
  "@types/ws": "^8.18.1",
92
93
  "@unocss/preset-icons": "^66.0.0",
93
94
  "@vue/runtime-core": "^3.5.13",
94
- "beasties": "^0.3.2",
95
+ "beasties": "^0.3.3",
95
96
  "css": "^3.0.0",
96
97
  "css-to-tailwind-translator": "^1.2.8",
97
98
  "quasar": "^2.18.1",
98
- "rollup": "^4.39.0",
99
+ "rollup": "^4.40.1",
99
100
  "typescript": "^5.8.3",
100
101
  "vue": "^3.5.13",
101
- "vue-router": "^4.5.0"
102
+ "vue-router": "^4.5.1"
102
103
  },
103
104
  "peerDependencies": {
104
105
  "@fastify/static": "^8.1.1",
105
- "fastify": "^5.2.2",
106
+ "fastify": "^5.3.2",
106
107
  "quasar": "^2.18.1",
107
108
  "vue": "^3.5.13",
108
- "vue-router": "^4.5.0"
109
+ "vue-router": "^4.5.1"
109
110
  },
110
111
  "publishConfig": {
111
112
  "access": "public",
@@ -19,8 +19,8 @@ export const getPkgJsonDir = (dir: URL): URL => {
19
19
  }
20
20
  return getPkgJsonDir(new URL('..', dir))
21
21
  }
22
- export const getAppDir = () =>
23
- getPkgJsonDir(new URL(`file://${process.cwd()}/`))
22
+ export const getAppDir = (dir?: URL) =>
23
+ getPkgJsonDir(dir ?? new URL(`file://${process.cwd()}/`))
24
24
  export const getCliDir = () => getPkgJsonDir(new URL('./', import.meta.url))
25
25
  export const getCliViteDir = (cliDir: URL) => new URL('src/vite/', cliDir)
26
26
  export const getSrcDir = (appDir: URL) => new URL('src/', appDir)
@@ -8,6 +8,7 @@ import type { ResolvedConfig, ViteDevServer } from 'vite'
8
8
  import type { Server } from 'net'
9
9
  import type { FastifyInstance } from 'fastify'
10
10
  import { readdir } from 'fs/promises'
11
+ import { loadSSRAssets } from '../frameworks/vue/fastify-ssr-plugin.js'
11
12
 
12
13
  const cli = cac('vitrify')
13
14
  cli
@@ -85,17 +86,23 @@ cli
85
86
  ...args,
86
87
  outDir: fileURLToPath(new URL('ssr/server/', baseOutDir))
87
88
  })
88
- ;({ prerender, onRendered } = await import(
89
+ ;({ prerender } = await import(
89
90
  new URL('ssr/server/prerender.mjs', baseOutDir).pathname
90
91
  ))
91
92
 
93
+ const { template, manifest, render, getRoutes, onRendered } =
94
+ await loadSSRAssets({
95
+ mode: 'ssg',
96
+ distDir: baseOutDir
97
+ })
98
+ const routes = await getRoutes()
99
+
92
100
  prerender({
93
101
  outDir: fileURLToPath(new URL('static/', baseOutDir)),
94
- templatePath: fileURLToPath(new URL('static/index.html', baseOutDir)),
95
- manifestPath: fileURLToPath(
96
- new URL('static/.vite/ssr-manifest.json', baseOutDir)
97
- ),
98
- entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir),
102
+ template,
103
+ manifest,
104
+ render,
105
+ routes,
99
106
  onRendered
100
107
  })
101
108
  break
@@ -49,8 +49,6 @@ export async function createVitrifyDevServer({
49
49
  '../app-urls.js'
50
50
  )
51
51
 
52
- const cliDir = getCliDir()
53
-
54
52
  if (!appDir) appDir = getAppDir()
55
53
  let config: InlineConfig = {}
56
54
  let ssrMode: 'server' | 'fastify' | undefined
@@ -66,52 +64,32 @@ export async function createVitrifyDevServer({
66
64
  base
67
65
  })
68
66
 
69
- config.logLevel = logLevel
70
-
71
- config.define = {
72
- ...config.define,
73
- __HOST__: `'${host}'`
74
- }
75
-
76
67
  const wsPort = await getFirstOpenPort(24678)
77
68
  if (config.server?.https) {
78
69
  exitLogs.push(
79
70
  `[warning] HTTPS mode enabled. Visit https://{hostname}:${wsPort} to enable a security exception for HMR.`
80
71
  )
81
72
  }
82
- config.server = {
83
- https: config.server?.https,
84
- hmr: {
85
- protocol: config.server?.https ? 'wss' : 'ws',
86
- port: wsPort
87
- },
88
- port,
89
- // middlewareMode: mode === 'ssr' ? 'ssr' : undefined,
90
- middlewareMode: ssr ? true : false,
91
- fs: {
92
- strict: false, // https://github.com/vitejs/vite/issues/8175
93
- allow: [
94
- searchForWorkspaceRoot(process.cwd()),
95
- searchForWorkspaceRoot(fileURLToPath(appDir)),
96
- searchForWorkspaceRoot(fileURLToPath(cliDir)),
97
- fileURLToPath(appDir)
98
- ]
99
- },
100
- watch: {
101
- // During tests we edit the files too fast and sometimes chokidar
102
- // misses change events, so enforce polling for consistency
103
- usePolling: true,
104
- interval: 100
105
- },
106
- host
107
- }
108
- if (ssr) config.appType = 'custom'
109
73
 
110
74
  const vitrifyDevServer = await (
111
75
  await import('vite')
112
76
  ).createServer({
113
77
  configFile: false,
114
- ...config
78
+ ...config,
79
+ logLevel,
80
+ define: {
81
+ ...config.define,
82
+ __HOST__: `'${host}'`
83
+ },
84
+ server: {
85
+ ...config.server,
86
+ host,
87
+ port,
88
+ hmr: {
89
+ protocol: config.server?.https ? 'wss' : 'ws',
90
+ port: wsPort
91
+ }
92
+ }
115
93
  })
116
94
 
117
95
  return vitrifyDevServer
@@ -170,9 +148,17 @@ export async function createServer({
170
148
  ? fileURLToPath(new URL('src/vite/fastify/entry.ts', cliDir))
171
149
  : fileURLToPath(new URL(`src/vite/${framework}/ssr/app.ts`, cliDir))
172
150
 
173
- ;({ setup, onRendered, vitrifyConfig } = await vite.ssrLoadModule(entryUrl))
151
+ const environment = vite.environments.ssr
152
+ ;({ setup, onRendered, vitrifyConfig } =
153
+ // @ts-expect-error missing types
154
+ await environment.runner.import(entryUrl))
155
+ // console.log(module)
156
+ // ;({ setup, onRendered, vitrifyConfig } = await vite.ssrLoadModule(entryUrl))
174
157
  app = fastify({
175
158
  logger: {
159
+ transport: {
160
+ target: '@fastify/one-line-logger'
161
+ },
176
162
  level: process.env.DEBUG
177
163
  ? 'debug'
178
164
  : process.env.PINO_LOG_LEVEL || 'info'