vitrify 0.1.0 → 0.2.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/README.md +86 -0
- package/dist/app-urls.js +36 -0
- package/dist/bin/build.js +73 -0
- package/dist/bin/cli.js +139 -0
- package/dist/bin/dev.js +108 -0
- package/dist/bin/run.js +29 -0
- package/dist/frameworks/vue/fastify-ssr-plugin.js +91 -0
- package/dist/frameworks/vue/prerender.js +29 -0
- package/dist/frameworks/vue/server.js +20 -0
- package/dist/helpers/logger.js +108 -0
- package/dist/helpers/routes.js +24 -0
- package/dist/helpers/utils.js +24 -0
- package/dist/index.js +341 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/quasar.js +299 -0
- package/dist/types/app-urls.d.ts +12 -0
- package/dist/types/bin/build.d.ts +8 -0
- package/dist/types/bin/cli.d.ts +2 -0
- package/dist/types/bin/dev.d.ts +15 -0
- package/dist/types/bin/run.d.ts +8 -0
- package/dist/types/bin/test.d.ts +3 -0
- package/dist/types/frameworks/vue/fastify-ssr-plugin.d.ts +14 -0
- package/dist/types/frameworks/vue/prerender.d.ts +8 -0
- package/dist/types/frameworks/vue/server.d.ts +9 -0
- package/dist/types/helpers/logger.d.ts +23 -0
- package/dist/types/helpers/routes.d.ts +2 -0
- package/dist/types/helpers/utils.d.ts +5 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/plugins/index.d.ts +7 -0
- package/dist/types/plugins/quasar.d.ts +16 -0
- package/dist/types/vitrify-config.d.ts +67 -0
- package/dist/vitrify-config.js +1 -0
- package/package.json +94 -19
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +137 -0
- package/src/node/frameworks/vue/prerender.ts +49 -0
- package/src/node/frameworks/vue/server.ts +38 -0
- package/src/vite/vue/csr/entry.ts +8 -0
- package/src/vite/vue/index.html +16 -0
- package/src/vite/vue/main.ts +89 -0
- package/src/vite/vue/ssr/entry-client.ts +9 -0
- package/src/vite/vue/ssr/entry-server.ts +97 -0
- package/src/vite/vue/ssr/fastify-ssr-plugin.ts +120 -0
- package/src/vite/vue/ssr/prerender.ts +4 -0
- package/src/vite/vue/ssr/server.ts +18 -0
- package/src/vite/vue/ssr/server.ts.bak +61 -0
- package/src/vite/vue/ssr/tsconfig.json +9 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import Components from 'unplugin-vue-components/vite';
|
|
3
|
+
// import { quasarDir as defaultQuasarDir } from '../app-urls.js'
|
|
4
|
+
// import { QuasarResolver } from '../resolver.js';
|
|
5
|
+
import { QuasarResolver } from 'unplugin-vue-components/resolvers';
|
|
6
|
+
import { getPkgJsonDir } from '../app-urls.js';
|
|
7
|
+
import { resolve } from 'import-meta-resolve';
|
|
8
|
+
export const injectSsrContext = (html, ssrContext) => html
|
|
9
|
+
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
10
|
+
let matches;
|
|
11
|
+
matches = found.match(/\sdir\s*=\s*['"]([^'"]*)['"]/i);
|
|
12
|
+
if (matches) {
|
|
13
|
+
start = start.replace(matches[0], '');
|
|
14
|
+
}
|
|
15
|
+
matches = found.match(/\slang\s*=\s*['"]([^'"]*)['"]/i);
|
|
16
|
+
if (matches) {
|
|
17
|
+
start = start.replace(matches[0], '');
|
|
18
|
+
}
|
|
19
|
+
return `${start} ${ssrContext._meta.htmlAttrs || ''} ${end}`;
|
|
20
|
+
})
|
|
21
|
+
.replace(/(<head[^>]*)(>)/i, (_, start, end) => `${start}${end}${ssrContext._meta.headTags || ''}`)
|
|
22
|
+
.replace(/(<\/head>)/i, (_, tag) => `${ssrContext._meta.resourceStyles || ''}${ssrContext._meta.endingHeadTags || ''}${tag}`)
|
|
23
|
+
.replace(/(<body[^>]*)(>)/i, (found, start, end) => {
|
|
24
|
+
let classes = ssrContext._meta.bodyClasses || '';
|
|
25
|
+
const matches = found.match(/\sclass\s*=\s*['"]([^'"]*)['"]/i);
|
|
26
|
+
if (matches) {
|
|
27
|
+
if (matches[1].length > 0) {
|
|
28
|
+
classes += ` ${matches[1]}`;
|
|
29
|
+
}
|
|
30
|
+
start = start.replace(matches[0], '');
|
|
31
|
+
}
|
|
32
|
+
return `${start} class="${classes.trim()}" ${ssrContext._meta.bodyAttrs || ''}${end}${ssrContext._meta.bodyTags || ''}`;
|
|
33
|
+
});
|
|
34
|
+
// export interface Configuration {
|
|
35
|
+
// ssr?: 'server' | 'client' | 'ssg' | false
|
|
36
|
+
// }
|
|
37
|
+
export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
38
|
+
// const extraPlugins: Plugin[] = []
|
|
39
|
+
// const ctx = {
|
|
40
|
+
// prod: process.env.MODE === 'production',
|
|
41
|
+
// dev: process.env.MODE === 'development',
|
|
42
|
+
// mode: {
|
|
43
|
+
// ssr: !!ssr,
|
|
44
|
+
// pwa: !!pwa
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
// let bootFilePaths: Record<string, any> = {}
|
|
48
|
+
// let components: string[] = []
|
|
49
|
+
let plugins = [];
|
|
50
|
+
// let css: string[] = []
|
|
51
|
+
let extras = [];
|
|
52
|
+
return [
|
|
53
|
+
// {
|
|
54
|
+
// name: 'legacy-support',
|
|
55
|
+
// enforce: 'pre',
|
|
56
|
+
// transform (code, id) {
|
|
57
|
+
// /**
|
|
58
|
+
// * ESM does not resolve an import to .default when there are multiple exports. The following is required to make the VuePlugin import of QCalendar work.
|
|
59
|
+
// */
|
|
60
|
+
// if (code.includes('app.use(VuePlugin)')) {
|
|
61
|
+
// code = code.replace(/app\.use\(VuePlugin\)/g, `app.use(VuePlugin.install ? VuePlugin : VuePlugin.default)`)
|
|
62
|
+
// }
|
|
63
|
+
// return code
|
|
64
|
+
// }
|
|
65
|
+
// },
|
|
66
|
+
Components({
|
|
67
|
+
resolvers: [QuasarResolver()]
|
|
68
|
+
}),
|
|
69
|
+
{
|
|
70
|
+
name: 'vite-plugin-quasar-setup',
|
|
71
|
+
enforce: 'pre',
|
|
72
|
+
config: async (config, env) => {
|
|
73
|
+
const { vitrify: { urls } = {}, quasar } = config;
|
|
74
|
+
const globalCss = quasar?.extras.map((extra) => `@quasar/extras/${extra}/${extra}.css`);
|
|
75
|
+
const localPackages = ['@quasar/extras', 'quasar'];
|
|
76
|
+
await (async () => {
|
|
77
|
+
for (const val of localPackages)
|
|
78
|
+
urls.packages[val] = getPkgJsonDir(new URL(await resolve(val, urls.app.href)));
|
|
79
|
+
})();
|
|
80
|
+
const onMountedHooks = [
|
|
81
|
+
async (instance) => {
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
const { proxy: { $q } } = instance;
|
|
84
|
+
$q.onSSRHydrated !== void 0 && $q.onSSRHydrated();
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
const bootFunctions = [
|
|
88
|
+
async ({ app, ssrContext, staticImports }) => {
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
// const quasarVuePlugin = (await import('quasar/vue-plugin')).default
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
const quasarPlugins = await import('virtual:quasar-plugins');
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
const directives = await import('quasar/src/directives.js');
|
|
95
|
+
app.use(staticImports.Quasar, {
|
|
96
|
+
plugins: quasarPlugins,
|
|
97
|
+
directives
|
|
98
|
+
}, ssrContext);
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
return {
|
|
102
|
+
vitrify: {
|
|
103
|
+
urls,
|
|
104
|
+
bootFunctions,
|
|
105
|
+
ssrFunctions: [injectSsrContext],
|
|
106
|
+
globalCss,
|
|
107
|
+
staticImports: {
|
|
108
|
+
quasar: ['Quasar']
|
|
109
|
+
},
|
|
110
|
+
hooks: {
|
|
111
|
+
onMounted: onMountedHooks
|
|
112
|
+
},
|
|
113
|
+
sass: {
|
|
114
|
+
additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'vite-plugin-quasar',
|
|
122
|
+
enforce: 'post',
|
|
123
|
+
// transformIndexHtml: {
|
|
124
|
+
// enforce: 'post',
|
|
125
|
+
// transform: (html) => {
|
|
126
|
+
// return html.replace(
|
|
127
|
+
// '<!--product-name-->',
|
|
128
|
+
// productName
|
|
129
|
+
// )
|
|
130
|
+
// }
|
|
131
|
+
// },
|
|
132
|
+
config: async (config, env) => {
|
|
133
|
+
// let appDir: URL
|
|
134
|
+
// let cliDir: URL
|
|
135
|
+
// let cwd: URL
|
|
136
|
+
// let quasarDir: URL
|
|
137
|
+
// let quasarConf: QuasarConf | undefined
|
|
138
|
+
const { quasar: quasarConf, vitrify: { urls } = {} } = config;
|
|
139
|
+
const quasarPkgJsonPath = new URL('package.json', urls?.packages?.quasar).pathname;
|
|
140
|
+
const { version } = JSON.parse(readFileSync(quasarPkgJsonPath, { encoding: 'utf-8' }));
|
|
141
|
+
// if (quasarConf?.boot) {
|
|
142
|
+
// bootFilePaths = (quasarConf.boot as (Record<string, any> | string)[])
|
|
143
|
+
// .filter(entry => {
|
|
144
|
+
// if (typeof entry === 'object') return (entry.server && (ssr === 'server'))
|
|
145
|
+
// else if (entry !== '') return true
|
|
146
|
+
// })
|
|
147
|
+
// .map(entry => {
|
|
148
|
+
// if (typeof entry === 'string') return entry
|
|
149
|
+
// else if (typeof entry === 'object') return entry.path
|
|
150
|
+
// })
|
|
151
|
+
// .reduce((acc, entry) => {
|
|
152
|
+
// if (entry[0] === '~') {
|
|
153
|
+
// const split = entry.substring(1).split('/')
|
|
154
|
+
// const name = split[0].replace(/[|&;$%@"<>()+,]/g, "");
|
|
155
|
+
// acc[name] = {
|
|
156
|
+
// path: new URL(`node_modules/${entry.substring(1)}`, urls?.app).pathname
|
|
157
|
+
// }
|
|
158
|
+
// } else {
|
|
159
|
+
// const name = entry.split('.')[0]
|
|
160
|
+
// acc[name] = {
|
|
161
|
+
// path: `src/boot/${entry}`
|
|
162
|
+
// }
|
|
163
|
+
// }
|
|
164
|
+
// return acc
|
|
165
|
+
// }, {})
|
|
166
|
+
// }
|
|
167
|
+
/**
|
|
168
|
+
* All components should have been auto-imported
|
|
169
|
+
*/
|
|
170
|
+
if (quasarConf?.framework?.plugins) {
|
|
171
|
+
if (!quasarConf.framework)
|
|
172
|
+
quasarConf.framework = {};
|
|
173
|
+
quasarConf.framework.plugins = [
|
|
174
|
+
...new Set(quasarConf.framework.plugins)
|
|
175
|
+
];
|
|
176
|
+
plugins = quasarConf?.framework.plugins;
|
|
177
|
+
}
|
|
178
|
+
// css = (quasarConf?.css || []).map((v => {
|
|
179
|
+
// if (v[0] === '~') {
|
|
180
|
+
// return v.slice(1)
|
|
181
|
+
// }
|
|
182
|
+
// return v
|
|
183
|
+
// })).map((v) => `@import '${v}'`)
|
|
184
|
+
extras = quasarConf?.extras || [];
|
|
185
|
+
return {
|
|
186
|
+
resolve: {
|
|
187
|
+
alias: [
|
|
188
|
+
{
|
|
189
|
+
find: 'quasar/wrappers',
|
|
190
|
+
replacement: new URL('quasar-wrappers.ts', urls?.cli).pathname
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
find: 'quasar/vue-plugin',
|
|
194
|
+
replacement: new URL('src/vue-plugin.js', urls?.packages?.quasar).pathname
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
find: 'quasar/plugins',
|
|
198
|
+
replacement: new URL('src/plugins.js', urls?.packages?.quasar)
|
|
199
|
+
.pathname
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
find: 'quasar/components',
|
|
203
|
+
replacement: new URL('src/components.js', urls?.packages?.quasar).pathname
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
find: 'quasar/composables',
|
|
207
|
+
replacement: new URL('src/composables.js', urls?.packages?.quasar).pathname
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
find: 'quasar/directives',
|
|
211
|
+
replacement: new URL('src/directives.js', urls?.packages?.quasar).pathname
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
find: 'quasar/src',
|
|
215
|
+
replacement: new URL('src/', urls?.packages?.quasar).pathname
|
|
216
|
+
},
|
|
217
|
+
// ...extras.map(extra => ({
|
|
218
|
+
// find: `@quasar/extras/${extra}/${extra}.css`,
|
|
219
|
+
// replacement: new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname
|
|
220
|
+
// })
|
|
221
|
+
// ),
|
|
222
|
+
{
|
|
223
|
+
find: 'quasar',
|
|
224
|
+
replacement: new URL('src/', urls?.packages?.quasar).pathname
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
find: `@quasar/extras`,
|
|
228
|
+
replacement: new URL('.', urls?.packages?.['@quasar/extras'])
|
|
229
|
+
.pathname
|
|
230
|
+
}
|
|
231
|
+
// { find: new RegExp('^quasar$'), replacement: new URL('src/index.all.js', urls?.packages?.quasar).pathname },
|
|
232
|
+
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' },
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
define: {
|
|
236
|
+
__DEV__: process.env.NODE_ENV !== 'production' || true,
|
|
237
|
+
__QUASAR_VERSION__: `'${version}'`,
|
|
238
|
+
__QUASAR_SSR__: !!ssr,
|
|
239
|
+
__QUASAR_SSR_SERVER__: ssr === 'server',
|
|
240
|
+
__QUASAR_SSR_CLIENT__: ssr === 'client',
|
|
241
|
+
__QUASAR_SSR_PWA__: ssr === 'client' && pwa
|
|
242
|
+
},
|
|
243
|
+
// css: {
|
|
244
|
+
// preprocessorOptions: {
|
|
245
|
+
// sass: {
|
|
246
|
+
// additionalData: `@import 'quasar/src/css/index.sass'`
|
|
247
|
+
// // [
|
|
248
|
+
// // // ...extras.map(extra => `@import "@quasar/extras/${extra}/${extra}.css"`),
|
|
249
|
+
// // // ...extras.map(extra => `@import ${new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname}`) || [],
|
|
250
|
+
// // // config.css?.preprocessorOptions?.sass?.additionalData,
|
|
251
|
+
// // `@import 'quasar/src/css/index.sass'`
|
|
252
|
+
// // ].join('\n')
|
|
253
|
+
// }
|
|
254
|
+
// }
|
|
255
|
+
// },
|
|
256
|
+
ssr: {
|
|
257
|
+
noExternal: ['quasar']
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: 'quasar-virtual-modules',
|
|
264
|
+
enforce: 'post',
|
|
265
|
+
config: async (config, env) => ({
|
|
266
|
+
resolve: {
|
|
267
|
+
alias: [
|
|
268
|
+
{ find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
}),
|
|
272
|
+
resolveId(id) {
|
|
273
|
+
switch (id) {
|
|
274
|
+
case 'virtual:quasar-plugins':
|
|
275
|
+
return 'virtual:quasar-plugins';
|
|
276
|
+
case 'virtual:quasar':
|
|
277
|
+
return { id: 'virtual:quasar', moduleSideEffects: false };
|
|
278
|
+
default:
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
load(id) {
|
|
283
|
+
if (id === 'virtual:quasar-plugins') {
|
|
284
|
+
return `export { ${plugins.join(',')} } from 'quasar'`;
|
|
285
|
+
}
|
|
286
|
+
else if (id === 'virtual:quasar') {
|
|
287
|
+
return `export * from 'quasar/src/plugins.js';
|
|
288
|
+
export * from 'quasar/src/components.js';
|
|
289
|
+
export * from 'quasar/src/composables.js';
|
|
290
|
+
export * from 'quasar/src/directives.js';
|
|
291
|
+
export * from 'quasar/src/utils.js';
|
|
292
|
+
export { default as Quasar } from 'quasar/src/install-quasar.js'`;
|
|
293
|
+
}
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
];
|
|
298
|
+
};
|
|
299
|
+
export default QuasarPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const getPkgJsonDir: (dir: URL) => URL;
|
|
2
|
+
export declare const getAppDir: () => URL;
|
|
3
|
+
export declare const getCliDir: () => URL;
|
|
4
|
+
export declare const getCliViteDir: (cliDir: URL) => URL;
|
|
5
|
+
export declare const getSrcDir: (appDir: URL) => URL;
|
|
6
|
+
export declare const getCwd: () => URL;
|
|
7
|
+
export declare const parsePath: (path: string, basePath: URL) => URL | undefined;
|
|
8
|
+
export declare const getProjectURLs: (appDir: URL, cliDir: URL) => {
|
|
9
|
+
src: (path: string) => URL;
|
|
10
|
+
app: (path: string) => URL;
|
|
11
|
+
cli: (path: string) => URL;
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/node --experimental-specifier-resolution=node
|
|
2
|
+
export declare function build(opts: {
|
|
3
|
+
ssr?: 'client' | 'server' | 'ssg';
|
|
4
|
+
base?: string;
|
|
5
|
+
outDir?: string;
|
|
6
|
+
appDir?: URL;
|
|
7
|
+
publicDir?: URL;
|
|
8
|
+
}): Promise<import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ViteDevServer, LogLevel } from 'vite';
|
|
3
|
+
import type { Server } from 'net';
|
|
4
|
+
export declare function createServer({ port, logLevel, mode, framework, host, appDir, publicDir }: {
|
|
5
|
+
port?: number;
|
|
6
|
+
logLevel?: LogLevel;
|
|
7
|
+
mode?: 'csr' | 'ssr';
|
|
8
|
+
framework?: 'vue';
|
|
9
|
+
host?: string;
|
|
10
|
+
appDir?: URL;
|
|
11
|
+
publicDir?: URL;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
server: Server;
|
|
14
|
+
vite: ViteDevServer;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FastifyPluginCallback, FastifyRequest, FastifyReply } from 'fastify';
|
|
2
|
+
import type { ViteDevServer } from 'vite';
|
|
3
|
+
import type { SsrFunction } from '../../vitrify-config.js';
|
|
4
|
+
export interface FastifySsrOptions {
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
provide?: (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown>>;
|
|
7
|
+
vite?: ViteDevServer;
|
|
8
|
+
cliDir?: URL;
|
|
9
|
+
appDir?: URL;
|
|
10
|
+
productName?: string;
|
|
11
|
+
ssrFunctions?: SsrFunction[];
|
|
12
|
+
}
|
|
13
|
+
declare const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions>;
|
|
14
|
+
export { fastifySsrPlugin };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SsrFunction } from '../../vitrify-config.js';
|
|
2
|
+
export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath, ssrFunctions }: {
|
|
3
|
+
outDir: string;
|
|
4
|
+
templatePath: string;
|
|
5
|
+
manifestPath: string;
|
|
6
|
+
entryServerPath: string;
|
|
7
|
+
ssrFunctions: SsrFunction[];
|
|
8
|
+
}) => Promise<void[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { FastifyInstance } from 'fastify';
|
|
3
|
+
import type { SsrFunction } from '../../vitrify-config.js';
|
|
4
|
+
export declare const createApp: ({ setup, appDir, baseUrl, ssrFunctions }: {
|
|
5
|
+
setup: (fastify: FastifyInstance) => any;
|
|
6
|
+
appDir: URL;
|
|
7
|
+
baseUrl?: string | undefined;
|
|
8
|
+
ssrFunctions?: SsrFunction[] | undefined;
|
|
9
|
+
}) => FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify").FastifyLoggerInstance> & PromiseLike<FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify").FastifyLoggerInstance>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Server } from 'net';
|
|
3
|
+
import type { ResolvedConfig } from 'vite';
|
|
4
|
+
export declare const clearConsole: () => void;
|
|
5
|
+
export declare const log: (msg?: string | undefined) => void;
|
|
6
|
+
export declare const warn: (msg?: string | undefined, pill?: string | undefined) => void;
|
|
7
|
+
export declare const fatal: (msg?: string | undefined, pill?: string | undefined) => never;
|
|
8
|
+
/**
|
|
9
|
+
* Extended approach - Compilation status & pills
|
|
10
|
+
*/
|
|
11
|
+
export declare const successPill: (msg?: string | undefined) => string;
|
|
12
|
+
export declare const infoPill: (msg?: string | undefined) => string;
|
|
13
|
+
export declare const errorPill: (msg?: string | undefined) => string;
|
|
14
|
+
export declare const warningPill: (msg?: string | undefined) => string;
|
|
15
|
+
export declare const success: (msg?: string | undefined, title?: string) => void;
|
|
16
|
+
export declare const getSuccess: (msg?: string | undefined, title?: string | undefined) => string;
|
|
17
|
+
export declare const info: (msg?: string | undefined, title?: string) => void;
|
|
18
|
+
export declare const getInfo: (msg?: string | undefined, title?: string | undefined) => string;
|
|
19
|
+
export declare const error: (msg?: string | undefined, title?: string) => void;
|
|
20
|
+
export declare const getError: (msg?: string | undefined, title?: string) => string;
|
|
21
|
+
export declare const warning: (msg?: string | undefined, title?: string) => void;
|
|
22
|
+
export declare const getWarning: (msg?: string | undefined, title?: string) => string;
|
|
23
|
+
export declare function printHttpServerUrls(server: Server, config: ResolvedConfig): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { InlineConfig } from 'vite';
|
|
2
|
+
import type { BootFunction, VitrifyConfig } from './vitrify-config.js';
|
|
3
|
+
import type { VitrifyContext } from './bin/run.js';
|
|
4
|
+
import type { VitrifyPlugin } from './plugins/index.js';
|
|
5
|
+
export declare const VIRTUAL_MODULES: string[];
|
|
6
|
+
export declare const baseConfig: ({ ssr, appDir, publicDir, command, mode, framework, pwa }: {
|
|
7
|
+
ssr?: "server" | "client" | "ssg" | undefined;
|
|
8
|
+
appDir?: URL | undefined;
|
|
9
|
+
publicDir?: URL | undefined;
|
|
10
|
+
command?: "build" | "dev" | "test" | undefined;
|
|
11
|
+
mode?: "production" | "development" | undefined;
|
|
12
|
+
framework?: "vue" | undefined;
|
|
13
|
+
pwa?: boolean | undefined;
|
|
14
|
+
}) => Promise<InlineConfig>;
|
|
15
|
+
export type { VitrifyConfig, VitrifyPlugin, VitrifyContext, BootFunction };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export declare type VitrifyPlugin = ({ ssr, mode, command }: {
|
|
3
|
+
ssr?: 'server' | 'client' | 'ssg' | false;
|
|
4
|
+
pwa?: boolean;
|
|
5
|
+
mode?: 'production' | 'development';
|
|
6
|
+
command?: 'build' | 'dev' | 'test';
|
|
7
|
+
}) => Promise<Plugin | Plugin[]> | Plugin | Plugin[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { VitrifyPlugin } from './index.js';
|
|
2
|
+
export interface QuasarConf {
|
|
3
|
+
ctx: Record<string, any>;
|
|
4
|
+
css: string[];
|
|
5
|
+
boot: string[];
|
|
6
|
+
framework: {
|
|
7
|
+
components?: string[];
|
|
8
|
+
directives?: string[];
|
|
9
|
+
plugins?: string[];
|
|
10
|
+
};
|
|
11
|
+
animations: string[];
|
|
12
|
+
extras: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare const injectSsrContext: (html: string, ssrContext: Record<string, any>) => string;
|
|
15
|
+
export declare const QuasarPlugin: VitrifyPlugin;
|
|
16
|
+
export default QuasarPlugin;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { FastifyInstance } from 'fastify';
|
|
2
|
+
import type { UserConfig } from 'vite';
|
|
3
|
+
import type { QuasarConf } from './plugins/quasar.js';
|
|
4
|
+
import type { ComponentInternalInstance } from '@vue/runtime-core';
|
|
5
|
+
export declare type BootFunction = ({ app, ssrContext, staticImports }: {
|
|
6
|
+
app: any;
|
|
7
|
+
ssrContext: Record<string, unknown>;
|
|
8
|
+
staticImports: Record<string, any>;
|
|
9
|
+
}) => Promise<void> | void;
|
|
10
|
+
export declare type OnMountedHook = (instance: ComponentInternalInstance) => Promise<void> | void;
|
|
11
|
+
export declare type StaticImports = Record<string, string[]>;
|
|
12
|
+
export declare type SsrFunction = (html: string, ssrContext: Record<string, any>) => string;
|
|
13
|
+
export interface VitrifyConfig extends UserConfig {
|
|
14
|
+
vitrify?: {
|
|
15
|
+
/**
|
|
16
|
+
* Global CSS imports
|
|
17
|
+
*/
|
|
18
|
+
globalCss?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Functions which run after initializing the app
|
|
21
|
+
*/
|
|
22
|
+
bootFunctions?: BootFunction[];
|
|
23
|
+
/**
|
|
24
|
+
* Functions which run on the server after rendering the app
|
|
25
|
+
*/
|
|
26
|
+
ssrFunctions?: SsrFunction[];
|
|
27
|
+
/**
|
|
28
|
+
* Static imports in the app: packageName: [imports]
|
|
29
|
+
*/
|
|
30
|
+
staticImports?: StaticImports;
|
|
31
|
+
hooks?: {
|
|
32
|
+
/**
|
|
33
|
+
* Functions which run in the onMounted hook of the app
|
|
34
|
+
*/
|
|
35
|
+
onMounted: OnMountedHook[];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Global SASS variables
|
|
39
|
+
*/
|
|
40
|
+
sass?: {
|
|
41
|
+
variables?: Record<string, string>;
|
|
42
|
+
additionalData?: string[];
|
|
43
|
+
};
|
|
44
|
+
fastify?: {
|
|
45
|
+
/**
|
|
46
|
+
* setup() is called directly after instantiating fastify. Use it to register your own plugins, routes etc.
|
|
47
|
+
*/
|
|
48
|
+
setup: (fastify: FastifyInstance) => any;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Product name of the application. Will be used for the HTML title tag
|
|
52
|
+
*/
|
|
53
|
+
productName?: string;
|
|
54
|
+
/**
|
|
55
|
+
* URL's for common dev paths and packages, automatically generated
|
|
56
|
+
*/
|
|
57
|
+
urls?: {
|
|
58
|
+
app?: URL;
|
|
59
|
+
cli?: URL;
|
|
60
|
+
src?: URL;
|
|
61
|
+
cwd?: URL;
|
|
62
|
+
packages?: Record<string, URL>;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
quasar?: QuasarConf;
|
|
66
|
+
}
|
|
67
|
+
export declare const defineConfig: (config: VitrifyConfig) => VitrifyConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defineConfig = (config) => config;
|