vitrify 0.12.2 → 0.13.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 +2 -1
- package/dist/index.js +15 -21
- package/dist/types/bin/dev.d.ts +2 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/vitrify-config.d.ts +5 -0
- package/package.json +4 -2
- package/src/node/bin/dev.ts +2 -1
- package/src/node/index.ts +18 -22
- package/src/node/vitrify-config.ts +5 -0
- package/src/vite/vue/main.ts +6 -13
- package/src/vite/vue/pwa.ts +8 -0
package/dist/bin/dev.js
CHANGED
|
@@ -135,7 +135,8 @@ ssr, framework = 'vue', host, appDir, publicDir, vite }) {
|
|
|
135
135
|
server = app.server;
|
|
136
136
|
if (ssr === 'fastify') {
|
|
137
137
|
vite.fastifyRestart = async function () {
|
|
138
|
-
if (vite && app
|
|
138
|
+
if (vite && app) {
|
|
139
|
+
await app.ready();
|
|
139
140
|
await app.close();
|
|
140
141
|
({ app, server } = await createServer({
|
|
141
142
|
ssr: 'fastify',
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { fileURLToPath } from 'url';
|
|
|
12
12
|
import { resolve } from './app-urls.js';
|
|
13
13
|
import { addOrReplaceTitle, appendToBody } from './helpers/utils.js';
|
|
14
14
|
import Components from 'unplugin-vue-components/vite';
|
|
15
|
+
import { VitePWA } from 'vite-plugin-pwa';
|
|
15
16
|
const internalServerModules = [
|
|
16
17
|
'util',
|
|
17
18
|
'vitrify',
|
|
@@ -144,7 +145,7 @@ async function bundleConfigFile(fileName, isESM = false) {
|
|
|
144
145
|
dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
|
-
export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command = 'build', mode = 'production', framework = 'vue',
|
|
148
|
+
export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command = 'build', mode = 'production', framework = 'vue', debug = false, productName }) => {
|
|
148
149
|
const { getAppDir, getCliDir, getCliViteDir, getSrcDir, getCwd } = await import('./app-urls.js');
|
|
149
150
|
if (!appDir) {
|
|
150
151
|
appDir = getAppDir();
|
|
@@ -216,6 +217,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
216
217
|
}
|
|
217
218
|
else {
|
|
218
219
|
}
|
|
220
|
+
const isPwa = !!vitrifyConfig.vitrify?.pwa || false;
|
|
219
221
|
const frameworkPlugins = [];
|
|
220
222
|
const resolvers = [];
|
|
221
223
|
for (const framework of Object.keys(configPluginMap)) {
|
|
@@ -224,7 +226,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
224
226
|
const resolver = await configResolverMap[framework]();
|
|
225
227
|
frameworkPlugins.push(await plugin({
|
|
226
228
|
ssr,
|
|
227
|
-
pwa
|
|
229
|
+
pwa: isPwa
|
|
228
230
|
}));
|
|
229
231
|
resolvers.push(resolver);
|
|
230
232
|
}
|
|
@@ -307,24 +309,6 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
307
309
|
return { id };
|
|
308
310
|
return;
|
|
309
311
|
},
|
|
310
|
-
// transform: (code, id) => {
|
|
311
|
-
// if (['main.ts', 'vitrify'].every((val) => id.includes(val))) {
|
|
312
|
-
// code =
|
|
313
|
-
// `${globalCss.map((css) => `import '${css}'`).join('\n')}\n` + code
|
|
314
|
-
// }
|
|
315
|
-
// if (['RootComponent.vue', 'vitrify'].every((val) => id.includes(val))) {
|
|
316
|
-
// console.log('lksdflkjsdf')
|
|
317
|
-
// const sass = [
|
|
318
|
-
// ...Object.entries(sassVariables).map(
|
|
319
|
-
// ([key, value]) => `${key}: ${value}`
|
|
320
|
-
// ),
|
|
321
|
-
// ...globalSass.map((sass) => `@import '${sass}'`)
|
|
322
|
-
// ].join('\n')
|
|
323
|
-
// code = code.replace(/<\/style>/, sass + '</style>')
|
|
324
|
-
// console.log(code)
|
|
325
|
-
// }
|
|
326
|
-
// return code
|
|
327
|
-
// },
|
|
328
312
|
load(id) {
|
|
329
313
|
if (id === 'virtual:vitrify-hooks') {
|
|
330
314
|
return `export const onBoot = [${onBootHooks
|
|
@@ -386,6 +370,15 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
386
370
|
resolvers
|
|
387
371
|
})
|
|
388
372
|
];
|
|
373
|
+
if (isPwa) {
|
|
374
|
+
plugins.unshift(VitePWA({
|
|
375
|
+
injectRegister: null,
|
|
376
|
+
workbox: {
|
|
377
|
+
globPatterns: ['**/*.{js,mjs,css,html,ico,png,svg,pdf}']
|
|
378
|
+
},
|
|
379
|
+
...vitrifyConfig.vitrify?.pwa
|
|
380
|
+
}));
|
|
381
|
+
}
|
|
389
382
|
if (command !== 'test') {
|
|
390
383
|
plugins.unshift({
|
|
391
384
|
name: 'html-transform',
|
|
@@ -563,7 +556,8 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
563
556
|
},
|
|
564
557
|
define: {
|
|
565
558
|
__HOST__: `'localhost'`,
|
|
566
|
-
__BASE_URL__: `'${base}'
|
|
559
|
+
__BASE_URL__: `'${base}'`,
|
|
560
|
+
__IS_PWA__: `${isPwa}`
|
|
567
561
|
}
|
|
568
562
|
};
|
|
569
563
|
return mergeConfig(config, vitrifyConfig);
|
package/dist/types/bin/dev.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
|
|
|
30
30
|
}): Promise<{
|
|
31
31
|
app: FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> | undefined;
|
|
32
32
|
server: Server;
|
|
33
|
-
config: Readonly<Omit<import("vite").UserConfig, "plugins" | "assetsInclude" | "optimizeDeps" | "worker"> & {
|
|
33
|
+
config: Readonly<Omit<import("vite").UserConfig, "build" | "plugins" | "css" | "assetsInclude" | "optimizeDeps" | "worker"> & {
|
|
34
34
|
configFile: string | undefined;
|
|
35
35
|
configFileDependencies: string[];
|
|
36
36
|
inlineConfig: InlineConfig;
|
|
@@ -48,6 +48,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
|
|
|
48
48
|
alias: import("vite").Alias[];
|
|
49
49
|
};
|
|
50
50
|
plugins: readonly import("vite").Plugin[];
|
|
51
|
+
css: import("vite").ResolvedCSSOptions | undefined;
|
|
51
52
|
esbuild: false | import("vite").ESBuildOptions;
|
|
52
53
|
server: import("vite").ResolvedServerOptions;
|
|
53
54
|
build: import("vite").ResolvedBuildOptions;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { BootFunction, VitrifyConfig, VitrifyConfigAsync, VitrifyCommands,
|
|
|
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
|
-
export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode, framework,
|
|
6
|
+
export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode, framework, debug, productName }: {
|
|
7
7
|
ssr?: VitrifySSRModes | undefined;
|
|
8
8
|
appDir?: URL | undefined;
|
|
9
9
|
publicDir?: URL | undefined;
|
|
@@ -11,7 +11,6 @@ export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode,
|
|
|
11
11
|
command?: VitrifyCommands | undefined;
|
|
12
12
|
mode?: VitrifyModes | undefined;
|
|
13
13
|
framework?: "vue" | undefined;
|
|
14
|
-
pwa?: boolean | undefined;
|
|
15
14
|
debug?: boolean | undefined;
|
|
16
15
|
productName?: string | undefined;
|
|
17
16
|
}) => Promise<InlineConfig>;
|
|
@@ -2,6 +2,7 @@ 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
4
|
import type { FastifyServerOptions } from 'fastify';
|
|
5
|
+
import type { VitePWAOptions } from 'vite-plugin-pwa';
|
|
5
6
|
export type BootFunction = ({ app, ssrContext, staticImports }: {
|
|
6
7
|
app: any;
|
|
7
8
|
ssrContext: Record<string, unknown>;
|
|
@@ -84,6 +85,10 @@ export interface VitrifyConfig extends UserConfig {
|
|
|
84
85
|
* Files which should be a seperate chunk
|
|
85
86
|
*/
|
|
86
87
|
manualChunks?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* Enables vite-plugin-pwa
|
|
90
|
+
*/
|
|
91
|
+
pwa?: Partial<VitePWAOptions>;
|
|
87
92
|
};
|
|
88
93
|
quasar?: QuasarConf;
|
|
89
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitrify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Stefan van Herwijnen",
|
|
6
6
|
"description": "Vite as your Full Stack development tool",
|
|
@@ -71,7 +71,9 @@
|
|
|
71
71
|
"ts-node": "^10.9.1",
|
|
72
72
|
"unplugin-vue-components": "^0.24.1",
|
|
73
73
|
"vite": "^4.3.4",
|
|
74
|
-
"
|
|
74
|
+
"vite-plugin-pwa": "^0.16.5",
|
|
75
|
+
"vitest": "^0.30.1",
|
|
76
|
+
"workbox-window": "^7.0.0"
|
|
75
77
|
},
|
|
76
78
|
"devDependencies": {
|
|
77
79
|
"@types/connect": "^3.4.35",
|
package/src/node/bin/dev.ts
CHANGED
|
@@ -202,7 +202,8 @@ export async function createServer({
|
|
|
202
202
|
|
|
203
203
|
if (ssr === 'fastify') {
|
|
204
204
|
vite.fastifyRestart = async function () {
|
|
205
|
-
if (vite && app
|
|
205
|
+
if (vite && app) {
|
|
206
|
+
await app.ready()
|
|
206
207
|
await app.close()
|
|
207
208
|
;({ app, server } = await createServer({
|
|
208
209
|
ssr: 'fastify',
|
package/src/node/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ import type { ManualChunksOption, RollupOptions } from 'rollup'
|
|
|
31
31
|
import { addOrReplaceTitle, appendToBody } from './helpers/utils.js'
|
|
32
32
|
import type { ComponentResolver } from 'unplugin-vue-components'
|
|
33
33
|
import Components from 'unplugin-vue-components/vite'
|
|
34
|
+
import { VitePWA } from 'vite-plugin-pwa'
|
|
34
35
|
|
|
35
36
|
const internalServerModules = [
|
|
36
37
|
'util',
|
|
@@ -197,7 +198,6 @@ export const baseConfig = async ({
|
|
|
197
198
|
command = 'build',
|
|
198
199
|
mode = 'production',
|
|
199
200
|
framework = 'vue',
|
|
200
|
-
pwa = false,
|
|
201
201
|
debug = false,
|
|
202
202
|
productName
|
|
203
203
|
}: {
|
|
@@ -208,7 +208,6 @@ export const baseConfig = async ({
|
|
|
208
208
|
command?: VitrifyCommands
|
|
209
209
|
mode?: VitrifyModes
|
|
210
210
|
framework?: VitrifyUIFrameworks
|
|
211
|
-
pwa?: boolean
|
|
212
211
|
debug?: boolean
|
|
213
212
|
productName?: string
|
|
214
213
|
}): Promise<InlineConfig> => {
|
|
@@ -289,6 +288,8 @@ export const baseConfig = async ({
|
|
|
289
288
|
} else {
|
|
290
289
|
}
|
|
291
290
|
|
|
291
|
+
const isPwa = !!vitrifyConfig.vitrify?.pwa || false
|
|
292
|
+
|
|
292
293
|
const frameworkPlugins = []
|
|
293
294
|
const resolvers = []
|
|
294
295
|
for (const framework of Object.keys(configPluginMap)) {
|
|
@@ -298,7 +299,7 @@ export const baseConfig = async ({
|
|
|
298
299
|
frameworkPlugins.push(
|
|
299
300
|
await plugin({
|
|
300
301
|
ssr,
|
|
301
|
-
pwa
|
|
302
|
+
pwa: isPwa
|
|
302
303
|
})
|
|
303
304
|
)
|
|
304
305
|
resolvers.push(resolver)
|
|
@@ -349,6 +350,7 @@ export const baseConfig = async ({
|
|
|
349
350
|
)
|
|
350
351
|
// code = code.replace(/<\/style>/, sass + '</style>')
|
|
351
352
|
}
|
|
353
|
+
|
|
352
354
|
return code
|
|
353
355
|
}
|
|
354
356
|
},
|
|
@@ -387,24 +389,6 @@ export const baseConfig = async ({
|
|
|
387
389
|
if (VIRTUAL_MODULES.includes(id)) return { id }
|
|
388
390
|
return
|
|
389
391
|
},
|
|
390
|
-
// transform: (code, id) => {
|
|
391
|
-
// if (['main.ts', 'vitrify'].every((val) => id.includes(val))) {
|
|
392
|
-
// code =
|
|
393
|
-
// `${globalCss.map((css) => `import '${css}'`).join('\n')}\n` + code
|
|
394
|
-
// }
|
|
395
|
-
// if (['RootComponent.vue', 'vitrify'].every((val) => id.includes(val))) {
|
|
396
|
-
// console.log('lksdflkjsdf')
|
|
397
|
-
// const sass = [
|
|
398
|
-
// ...Object.entries(sassVariables).map(
|
|
399
|
-
// ([key, value]) => `${key}: ${value}`
|
|
400
|
-
// ),
|
|
401
|
-
// ...globalSass.map((sass) => `@import '${sass}'`)
|
|
402
|
-
// ].join('\n')
|
|
403
|
-
// code = code.replace(/<\/style>/, sass + '</style>')
|
|
404
|
-
// console.log(code)
|
|
405
|
-
// }
|
|
406
|
-
// return code
|
|
407
|
-
// },
|
|
408
392
|
load(id) {
|
|
409
393
|
if (id === 'virtual:vitrify-hooks') {
|
|
410
394
|
return `export const onBoot = [${onBootHooks
|
|
@@ -472,6 +456,17 @@ export const baseConfig = async ({
|
|
|
472
456
|
resolvers
|
|
473
457
|
})
|
|
474
458
|
]
|
|
459
|
+
if (isPwa) {
|
|
460
|
+
plugins.unshift(
|
|
461
|
+
VitePWA({
|
|
462
|
+
injectRegister: null,
|
|
463
|
+
workbox: {
|
|
464
|
+
globPatterns: ['**/*.{js,mjs,css,html,ico,png,svg,pdf}']
|
|
465
|
+
},
|
|
466
|
+
...vitrifyConfig.vitrify?.pwa
|
|
467
|
+
})
|
|
468
|
+
)
|
|
469
|
+
}
|
|
475
470
|
if (command !== 'test') {
|
|
476
471
|
plugins.unshift({
|
|
477
472
|
name: 'html-transform',
|
|
@@ -659,7 +654,8 @@ export const baseConfig = async ({
|
|
|
659
654
|
},
|
|
660
655
|
define: {
|
|
661
656
|
__HOST__: `'localhost'`,
|
|
662
|
-
__BASE_URL__: `'${base}'
|
|
657
|
+
__BASE_URL__: `'${base}'`,
|
|
658
|
+
__IS_PWA__: `${isPwa}`
|
|
663
659
|
}
|
|
664
660
|
} as VitrifyConfig
|
|
665
661
|
|
|
@@ -2,6 +2,7 @@ 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
4
|
import type { FastifyServerOptions } from 'fastify'
|
|
5
|
+
import type { VitePWAOptions } from 'vite-plugin-pwa'
|
|
5
6
|
import { ComponentResolver } from 'unplugin-vue-components'
|
|
6
7
|
|
|
7
8
|
export type BootFunction = ({
|
|
@@ -106,6 +107,10 @@ export interface VitrifyConfig extends UserConfig {
|
|
|
106
107
|
* Files which should be a seperate chunk
|
|
107
108
|
*/
|
|
108
109
|
manualChunks?: string[]
|
|
110
|
+
/**
|
|
111
|
+
* Enables vite-plugin-pwa
|
|
112
|
+
*/
|
|
113
|
+
pwa?: Partial<VitePWAOptions>
|
|
109
114
|
}
|
|
110
115
|
quasar?: QuasarConf
|
|
111
116
|
}
|
package/src/vite/vue/main.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { onBoot, onMounted } from 'virtual:vitrify-hooks'
|
|
|
12
12
|
import routes from 'src/router/routes'
|
|
13
13
|
import * as staticImports from 'virtual:static-imports'
|
|
14
14
|
import App from 'src/App.vue'
|
|
15
|
+
|
|
15
16
|
import RootComponent from './RootComponent.vue'
|
|
16
17
|
interface ssrContext {
|
|
17
18
|
ssr: boolean
|
|
@@ -28,20 +29,7 @@ export async function createApp(
|
|
|
28
29
|
ssrContext?: ssrContext
|
|
29
30
|
) {
|
|
30
31
|
let app
|
|
31
|
-
// const RootComponent = {
|
|
32
|
-
// name: 'AppWrapper',
|
|
33
|
-
// setup(props) {
|
|
34
|
-
// const instance = getCurrentInstance()
|
|
35
|
-
|
|
36
|
-
// onMountedVue(async () => {
|
|
37
|
-
// for (let fn of onMounted) {
|
|
38
|
-
// await fn(instance, staticImports)
|
|
39
|
-
// }
|
|
40
|
-
// })
|
|
41
32
|
|
|
42
|
-
// return () => h(App, props)
|
|
43
|
-
// }
|
|
44
|
-
// }
|
|
45
33
|
if (ssr) {
|
|
46
34
|
app = createSSRApp(RootComponent)
|
|
47
35
|
} else {
|
|
@@ -90,5 +78,10 @@ export async function createApp(
|
|
|
90
78
|
await fn({ app, ssrContext, staticImports })
|
|
91
79
|
}
|
|
92
80
|
|
|
81
|
+
if (__IS_PWA__ && typeof window !== 'undefined') {
|
|
82
|
+
const { registerPWA } = await import('./pwa.js')
|
|
83
|
+
registerPWA(router)
|
|
84
|
+
}
|
|
85
|
+
|
|
93
86
|
return { app, router, routes }
|
|
94
87
|
}
|