vitrify 0.11.5 → 0.11.7

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.
@@ -1,6 +1,6 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { routesToPaths } from '../../helpers/routes.js';
3
- import { appendToHead } from '../../helpers/utils.js';
3
+ import { appendToHead, addOrReplaceAppDiv } from '../../helpers/utils.js';
4
4
  export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath, onRendered }) => {
5
5
  const promises = [];
6
6
  const template = (await fs.readFile(templatePath)).toString();
@@ -23,9 +23,8 @@ export const prerender = async ({ outDir, templatePath, manifestPath, entryServe
23
23
  res: {}
24
24
  };
25
25
  const [appHtml, preloadLinks] = await render(url, manifest, ssrContext);
26
- let html = template.replace(`<!--app-html-->`, appHtml);
26
+ let html = addOrReplaceAppDiv(appHtml, template);
27
27
  html = appendToHead(preloadLinks, html);
28
- // html = appendToBody(preloadLinks, html)
29
28
  if (onRendered?.length) {
30
29
  for (const ssrFunction of onRendered) {
31
30
  html = ssrFunction(html, ssrContext);
package/dist/index.js CHANGED
@@ -156,9 +156,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
156
156
  const fastifyDir = new URL('fastify/', cliViteDir);
157
157
  if (!publicDir)
158
158
  publicDir = new URL('public/', appDir);
159
- /**
160
- * TODO:Perform some manual check if command is run inside a Quasar Project
161
- */
162
159
  let vitrifyConfig;
163
160
  try {
164
161
  if (fs.existsSync(new URL('vitrify.config.ts', appDir).pathname)) {
@@ -233,7 +230,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
233
230
  let globalCss = [];
234
231
  let staticImports;
235
232
  let sassVariables;
236
- let additionalData;
237
233
  let globalSass;
238
234
  let serverModules = internalServerModules;
239
235
  if (vitrifyConfig.vitrify?.ssr?.serverModules)
@@ -280,7 +276,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
280
276
  staticImports = config.vitrify?.staticImports || {};
281
277
  sassVariables = config.vitrify?.sass?.variables || {};
282
278
  globalSass = config.vitrify?.sass?.global || [];
283
- additionalData = config.vitrify?.sass?.additionalData || [];
284
279
  return;
285
280
  },
286
281
  configureServer(server) {
@@ -378,16 +373,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
378
373
  plugins.unshift({
379
374
  name: 'html-transform',
380
375
  enforce: 'pre',
381
- // transform: (code, id) => {
382
- // if (id.endsWith('App.vue')) {
383
- // code =
384
- // code +
385
- // `<style lang="sass">
386
- // // do not remove, required for additionalData import
387
- // </style>`
388
- // }
389
- // return code
390
- // },
391
376
  transformIndexHtml: {
392
377
  enforce: 'pre',
393
378
  transform: (html) => {
@@ -1,15 +1,15 @@
1
1
  import type { InlineConfig } from 'vite';
2
- import type { BootFunction, VitrifyConfig } from './vitrify-config.js';
2
+ import type { BootFunction, VitrifyConfig, VitrifyConfigAsync, VitrifyCommands, VitrifyModes, VitrifyUIFrameworks, VitrifySSRModes } from './vitrify-config.js';
3
3
  import type { VitrifyContext } from './bin/run.js';
4
4
  import type { VitrifyPlugin } from './plugins/index.js';
5
5
  export declare const VIRTUAL_MODULES: string[];
6
6
  export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode, framework, pwa, debug, productName }: {
7
- ssr?: "server" | "client" | "ssg" | "fastify" | undefined;
7
+ ssr?: VitrifySSRModes | undefined;
8
8
  appDir?: URL | undefined;
9
9
  publicDir?: URL | undefined;
10
10
  base?: string | undefined;
11
- command?: "build" | "dev" | "test" | undefined;
12
- mode?: "production" | "development" | undefined;
11
+ command?: VitrifyCommands | undefined;
12
+ mode?: VitrifyModes | undefined;
13
13
  framework?: "vue" | undefined;
14
14
  pwa?: boolean | undefined;
15
15
  debug?: boolean | undefined;
@@ -17,4 +17,4 @@ export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode,
17
17
  }) => Promise<InlineConfig>;
18
18
  export declare const vitrifyDir: URL;
19
19
  export { prerender } from './frameworks/vue/prerender.js';
20
- export type { VitrifyConfig, VitrifyPlugin, VitrifyContext, BootFunction };
20
+ export type { VitrifyConfig, VitrifyConfigAsync, VitrifyPlugin, VitrifyContext, BootFunction };
@@ -51,7 +51,6 @@ export interface VitrifyConfig extends UserConfig {
51
51
  */
52
52
  sass?: {
53
53
  variables?: Record<string, string>;
54
- additionalData?: string[];
55
54
  global?: string[];
56
55
  };
57
56
  /**
@@ -88,5 +87,12 @@ export interface VitrifyConfig extends UserConfig {
88
87
  };
89
88
  quasar?: QuasarConf;
90
89
  }
91
- export type VitrifyConfigAsync = VitrifyConfig | ((mode: string, command: string) => Promise<VitrifyConfig>);
90
+ export type VitrifyCommands = 'build' | 'dev' | 'test';
91
+ export type VitrifyModes = 'production' | 'development';
92
+ export type VitrifyUIFrameworks = 'vue';
93
+ export type VitrifySSRModes = 'client' | 'server' | 'ssg' | 'fastify';
94
+ export type VitrifyConfigAsync = ({ mode, command }: {
95
+ mode: VitrifyModes;
96
+ command: VitrifyCommands;
97
+ }) => Promise<VitrifyConfig>;
92
98
  export declare const defineConfig: (config: VitrifyConfig) => VitrifyConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.11.5",
3
+ "version": "0.11.7",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Vite as your Full Stack development tool",
@@ -52,6 +52,7 @@
52
52
  "@fastify/static": "^6.9.0",
53
53
  "@quasar/extras": "^1.15.11",
54
54
  "@vitejs/plugin-vue": "^4.0.0",
55
+ "ajv": "^8.12.0",
55
56
  "builtin-modules": "^3.3.0",
56
57
  "cac": "^6.7.14",
57
58
  "chalk": "^5.2.0",
@@ -1,7 +1,7 @@
1
1
  import { promises as fs } from 'fs'
2
2
  import type { OnRenderedHook } from 'src/node/vitrify-config.js'
3
3
  import { routesToPaths } from '../../helpers/routes.js'
4
- import { appendToHead, appendToBody } from '../../helpers/utils.js'
4
+ import { appendToHead, addOrReplaceAppDiv } from '../../helpers/utils.js'
5
5
 
6
6
  export const prerender = async ({
7
7
  outDir,
@@ -31,6 +31,7 @@ export const prerender = async ({
31
31
  inlineFonts: true,
32
32
  preloadFonts: true
33
33
  })
34
+
34
35
  for (const url of paths) {
35
36
  const filename =
36
37
  (url.endsWith('/') ? 'index' : url.replace(/^\//g, '')) + '.html'
@@ -41,10 +42,8 @@ export const prerender = async ({
41
42
  }
42
43
  const [appHtml, preloadLinks] = await render(url, manifest, ssrContext)
43
44
 
44
- let html = template.replace(`<!--app-html-->`, appHtml)
45
-
45
+ let html = addOrReplaceAppDiv(appHtml, template)
46
46
  html = appendToHead(preloadLinks, html)
47
- // html = appendToBody(preloadLinks, html)
48
47
 
49
48
  if (onRendered?.length) {
50
49
  for (const ssrFunction of onRendered) {
package/src/node/index.ts CHANGED
@@ -14,6 +14,11 @@ import type {
14
14
  BootFunction,
15
15
  OnMountedHook,
16
16
  VitrifyConfig,
17
+ VitrifyConfigAsync,
18
+ VitrifyCommands,
19
+ VitrifyModes,
20
+ VitrifyUIFrameworks,
21
+ VitrifySSRModes,
17
22
  OnRenderedHook,
18
23
  OnBootHook,
19
24
  OnSetupFile
@@ -195,13 +200,13 @@ export const baseConfig = async ({
195
200
  debug = false,
196
201
  productName
197
202
  }: {
198
- ssr?: 'client' | 'server' | 'ssg' | 'fastify'
203
+ ssr?: VitrifySSRModes
199
204
  appDir?: URL
200
205
  publicDir?: URL
201
206
  base?: string
202
- command?: 'build' | 'dev' | 'test'
203
- mode?: 'production' | 'development'
204
- framework?: 'vue'
207
+ command?: VitrifyCommands
208
+ mode?: VitrifyModes
209
+ framework?: VitrifyUIFrameworks
205
210
  pwa?: boolean
206
211
  debug?: boolean
207
212
  productName?: string
@@ -219,18 +224,8 @@ export const baseConfig = async ({
219
224
  const fastifyDir = new URL('fastify/', cliViteDir)
220
225
 
221
226
  if (!publicDir) publicDir = new URL('public/', appDir)
222
- /**
223
- * TODO:Perform some manual check if command is run inside a Quasar Project
224
- */
225
- let vitrifyConfig:
226
- | VitrifyConfig
227
- | (({
228
- mode,
229
- command
230
- }: {
231
- mode: string
232
- command: string
233
- }) => Promise<VitrifyConfig> | VitrifyConfig)
227
+
228
+ let vitrifyConfig: VitrifyConfig | VitrifyConfigAsync
234
229
 
235
230
  try {
236
231
  if (fs.existsSync(new URL('vitrify.config.ts', appDir).pathname)) {
@@ -311,7 +306,6 @@ export const baseConfig = async ({
311
306
  let globalCss: string[] = []
312
307
  let staticImports: StaticImports
313
308
  let sassVariables: Record<string, string>
314
- let additionalData: string[]
315
309
  let globalSass: string[]
316
310
  let serverModules: string[] = internalServerModules
317
311
 
@@ -366,7 +360,6 @@ export const baseConfig = async ({
366
360
  staticImports = config.vitrify?.staticImports || {}
367
361
  sassVariables = config.vitrify?.sass?.variables || {}
368
362
  globalSass = config.vitrify?.sass?.global || []
369
- additionalData = config.vitrify?.sass?.additionalData || []
370
363
 
371
364
  return
372
365
  },
@@ -465,16 +458,6 @@ export const baseConfig = async ({
465
458
  plugins.unshift({
466
459
  name: 'html-transform',
467
460
  enforce: 'pre',
468
- // transform: (code, id) => {
469
- // if (id.endsWith('App.vue')) {
470
- // code =
471
- // code +
472
- // `<style lang="sass">
473
- // // do not remove, required for additionalData import
474
- // </style>`
475
- // }
476
- // return code
477
- // },
478
461
  transformIndexHtml: {
479
462
  enforce: 'pre',
480
463
  transform: (html) => {
@@ -659,4 +642,10 @@ export const baseConfig = async ({
659
642
 
660
643
  export const vitrifyDir = new URL('..', import.meta.url)
661
644
  export { prerender } from './frameworks/vue/prerender.js'
662
- export type { VitrifyConfig, VitrifyPlugin, VitrifyContext, BootFunction }
645
+ export type {
646
+ VitrifyConfig,
647
+ VitrifyConfigAsync,
648
+ VitrifyPlugin,
649
+ VitrifyContext,
650
+ BootFunction
651
+ }
@@ -73,7 +73,6 @@ export interface VitrifyConfig extends UserConfig {
73
73
  */
74
74
  sass?: {
75
75
  variables?: Record<string, string>
76
- additionalData?: string[]
77
76
  global?: string[]
78
77
  }
79
78
  /**
@@ -111,8 +110,17 @@ export interface VitrifyConfig extends UserConfig {
111
110
  quasar?: QuasarConf
112
111
  }
113
112
 
114
- export type VitrifyConfigAsync =
115
- | VitrifyConfig
116
- | ((mode: string, command: string) => Promise<VitrifyConfig>)
113
+ export type VitrifyCommands = 'build' | 'dev' | 'test'
114
+ export type VitrifyModes = 'production' | 'development'
115
+ export type VitrifyUIFrameworks = 'vue'
116
+ export type VitrifySSRModes = 'client' | 'server' | 'ssg' | 'fastify'
117
+
118
+ export type VitrifyConfigAsync = ({
119
+ mode,
120
+ command
121
+ }: {
122
+ mode: VitrifyModes
123
+ command: VitrifyCommands
124
+ }) => Promise<VitrifyConfig>
117
125
 
118
126
  export const defineConfig = (config: VitrifyConfig) => config