vitrify 0.6.18 → 0.7.2
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 +4 -2
- package/dist/frameworks/vue/fastify-ssr-plugin.js +3 -3
- package/dist/frameworks/vue/server.js +5 -5
- package/dist/index.js +29 -128
- package/dist/plugins/quasar.js +16 -108
- package/dist/types/bin/dev.d.ts +3 -4
- package/dist/types/frameworks/vue/server.d.ts +2 -2
- package/dist/types/vitrify-config.d.ts +2 -0
- package/package.json +21 -21
- package/src/node/bin/dev.ts +7 -7
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +3 -3
- package/src/node/frameworks/vue/server.ts +6 -6
- package/src/node/index.ts +30 -138
- package/src/node/plugins/quasar.ts +18 -115
- package/src/node/vitrify-config.ts +2 -0
- package/src/vite/fastify/entry.ts +1 -0
- package/src/vite/fastify/server.ts +3 -2
package/dist/bin/dev.js
CHANGED
|
@@ -77,15 +77,17 @@ 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));
|
|
86
87
|
const app = fastify({
|
|
87
88
|
logger: false,
|
|
88
|
-
https: vite.config.server.https
|
|
89
|
+
https: vite.config.server.https,
|
|
90
|
+
...vitrifyConfig.vitrify?.ssr?.fastify
|
|
89
91
|
});
|
|
90
92
|
if (process.env)
|
|
91
93
|
process.env.MODE = 'development';
|
|
@@ -2,9 +2,6 @@ import fastifyStatic from '@fastify/static';
|
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
3
|
import { componentsModules, collectCss } from '../../helpers/collect-css-ssr.js';
|
|
4
4
|
const fastifySsrPlugin = async (fastify, options, done) => {
|
|
5
|
-
options.vitrifyDir =
|
|
6
|
-
options.vitrifyDir || (await import('vitrify')).vitrifyDir;
|
|
7
|
-
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir);
|
|
8
5
|
options.baseUrl = options.baseUrl || '/';
|
|
9
6
|
options.mode = options.mode || process.env.MODE || import.meta.env.MODE;
|
|
10
7
|
options.appDir = options.appDir || new URL('../../..', import.meta.url);
|
|
@@ -12,6 +9,9 @@ const fastifySsrPlugin = async (fastify, options, done) => {
|
|
|
12
9
|
options.baseUrl.charAt(0) !== '/')
|
|
13
10
|
throw new Error('baseUrl should start and end with a /');
|
|
14
11
|
if (options.mode === 'development') {
|
|
12
|
+
options.vitrifyDir =
|
|
13
|
+
options.vitrifyDir || (await import('vitrify')).vitrifyDir;
|
|
14
|
+
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir);
|
|
15
15
|
// if (!options.vitrifyDir)
|
|
16
16
|
// throw new Error('Option vitrifyDir cannot be undefined')
|
|
17
17
|
// if (!options.vite) throw new Error('Option vite cannot be undefined')
|
|
@@ -10,10 +10,10 @@ export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered,
|
|
|
10
10
|
onRendered,
|
|
11
11
|
mode
|
|
12
12
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
if (onSetup?.length) {
|
|
14
|
+
for (const setup of onSetup) {
|
|
15
|
+
setup(app);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
18
|
return app;
|
|
19
19
|
};
|
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)) {
|
|
@@ -189,7 +183,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
189
183
|
let onRenderedHooks;
|
|
190
184
|
let onMountedHooks;
|
|
191
185
|
let onSetupFiles;
|
|
192
|
-
let globalCss;
|
|
186
|
+
let globalCss = [];
|
|
193
187
|
let staticImports;
|
|
194
188
|
let sassVariables;
|
|
195
189
|
let additionalData;
|
|
@@ -201,32 +195,12 @@ 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',
|
|
228
202
|
enforce: 'post',
|
|
229
|
-
config:
|
|
203
|
+
config: (config, env) => {
|
|
230
204
|
onBootHooks = config.vitrify?.hooks?.onBoot || [];
|
|
231
205
|
onRenderedHooks = config.vitrify?.hooks?.onRendered || [];
|
|
232
206
|
onMountedHooks = config.vitrify?.hooks?.onMounted || [];
|
|
@@ -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) => {
|
|
@@ -261,8 +221,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
261
221
|
},
|
|
262
222
|
configResolved: (config) => {
|
|
263
223
|
if (process.env.DEBUG) {
|
|
264
|
-
console.log(config
|
|
265
|
-
console.log(config.optimizeDeps);
|
|
224
|
+
console.log(config);
|
|
266
225
|
}
|
|
267
226
|
},
|
|
268
227
|
resolveId(id) {
|
|
@@ -290,24 +249,21 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
290
249
|
.join(', ')}]
|
|
291
250
|
export const onSetup = []
|
|
292
251
|
${onSetupFiles
|
|
293
|
-
.map((url, index) =>
|
|
294
|
-
.
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
252
|
+
.map((url, index) => {
|
|
253
|
+
const varName = url.pathname
|
|
254
|
+
.replaceAll('/', '')
|
|
255
|
+
.replaceAll('.', '')
|
|
256
|
+
.replaceAll('-', '');
|
|
257
|
+
return `import ${varName} from '${url.pathname}'; onSetup.push(${varName})`;
|
|
258
|
+
})
|
|
298
259
|
.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
260
|
}
|
|
308
261
|
else if (id === 'virtual:static-imports') {
|
|
309
262
|
return `${Object.entries(staticImports)
|
|
310
|
-
.map(([key, value]) =>
|
|
263
|
+
.map(([key, value]) => {
|
|
264
|
+
const deduped = [...new Set(value)];
|
|
265
|
+
return `export { ${deduped.join(',')} } from '${key}';`;
|
|
266
|
+
})
|
|
311
267
|
.join('\n')}`;
|
|
312
268
|
}
|
|
313
269
|
else if (id === 'vitrify.sass') {
|
|
@@ -330,16 +286,16 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
330
286
|
plugins.unshift({
|
|
331
287
|
name: 'html-transform',
|
|
332
288
|
enforce: 'pre',
|
|
333
|
-
transform: (code, id) => {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
// do not remove, required for additionalData import
|
|
339
|
-
</style
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
},
|
|
289
|
+
// transform: (code, id) => {
|
|
290
|
+
// if (id.endsWith('App.vue')) {
|
|
291
|
+
// code =
|
|
292
|
+
// code +
|
|
293
|
+
// `<style lang="sass">
|
|
294
|
+
// // do not remove, required for additionalData import
|
|
295
|
+
// </style>`
|
|
296
|
+
// }
|
|
297
|
+
// return code
|
|
298
|
+
// },
|
|
343
299
|
transformIndexHtml: {
|
|
344
300
|
enforce: 'pre',
|
|
345
301
|
transform: (html) => {
|
|
@@ -370,6 +326,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
370
326
|
config: (config, env) => {
|
|
371
327
|
if (config.vitrify?.productName)
|
|
372
328
|
productName = config.vitrify?.productName;
|
|
329
|
+
return;
|
|
373
330
|
},
|
|
374
331
|
transformIndexHtml: {
|
|
375
332
|
enforce: 'post',
|
|
@@ -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:
|
|
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:
|
|
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
|
package/dist/plugins/quasar.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { resolvePackageData } from 'vite';
|
|
2
2
|
import Components from 'unplugin-vue-components/vite';
|
|
3
|
-
// import { quasarDir as defaultQuasarDir } from '../app-urls.js'
|
|
4
|
-
// import { QuasarResolver } from '../resolver.js';
|
|
5
3
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers';
|
|
6
4
|
export const injectSsrContext = (html, ssrContext) => html
|
|
7
5
|
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
@@ -79,7 +77,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
79
77
|
const directives = await import('virtual:quasar-directives');
|
|
80
78
|
// @ts-ignore
|
|
81
79
|
const { default: lang } = await import('virtual:quasar-lang');
|
|
82
|
-
console.log(lang);
|
|
83
80
|
app.use(staticImports?.Quasar, {
|
|
84
81
|
plugins: quasarPlugins,
|
|
85
82
|
directives,
|
|
@@ -87,45 +84,10 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
87
84
|
}, ssrContext);
|
|
88
85
|
}
|
|
89
86
|
];
|
|
90
|
-
return {
|
|
91
|
-
vitrify: {
|
|
92
|
-
urls,
|
|
93
|
-
globalCss,
|
|
94
|
-
staticImports: {
|
|
95
|
-
quasar: ['Quasar']
|
|
96
|
-
},
|
|
97
|
-
hooks: {
|
|
98
|
-
onBoot: onBootHooks,
|
|
99
|
-
onMounted: onMountedHooks,
|
|
100
|
-
onRendered: [injectSsrContext]
|
|
101
|
-
},
|
|
102
|
-
sass: {
|
|
103
|
-
global: ['quasar/src/css/index.sass']
|
|
104
|
-
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
name: 'vite-plugin-quasar',
|
|
112
|
-
enforce: 'post',
|
|
113
|
-
config: async (config, env) => {
|
|
114
|
-
const { quasar, vitrify: { urls } = {} } = config;
|
|
115
87
|
if (quasar)
|
|
116
88
|
quasarConf = quasar;
|
|
117
89
|
if (!quasarConf.framework.lang && config.vitrify?.lang)
|
|
118
90
|
quasarConf.framework.lang = config.vitrify.lang;
|
|
119
|
-
// const quasarPkgJsonPath = new URL(
|
|
120
|
-
// 'package.json',
|
|
121
|
-
// urls?.packages?.quasar
|
|
122
|
-
// ).pathname
|
|
123
|
-
// const { version } = JSON.parse(
|
|
124
|
-
// readFileSync(quasarPkgJsonPath, { encoding: 'utf-8' })
|
|
125
|
-
// )
|
|
126
|
-
// const { version } = await import('quasar/package.json', {
|
|
127
|
-
// assert: { type: 'json' }
|
|
128
|
-
// })
|
|
129
91
|
/**
|
|
130
92
|
* Importing package.json is problematic
|
|
131
93
|
*/
|
|
@@ -142,75 +104,28 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
142
104
|
plugins = quasarConf?.framework.plugins;
|
|
143
105
|
}
|
|
144
106
|
return {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
107
|
+
vitrify: {
|
|
108
|
+
urls,
|
|
109
|
+
globalCss,
|
|
110
|
+
staticImports: {
|
|
111
|
+
quasar: ['Quasar']
|
|
112
|
+
},
|
|
113
|
+
hooks: {
|
|
114
|
+
onBoot: onBootHooks,
|
|
115
|
+
onMounted: onMountedHooks,
|
|
116
|
+
onRendered: [injectSsrContext]
|
|
117
|
+
},
|
|
118
|
+
sass: {
|
|
119
|
+
global: ['quasar/src/css/index.sass']
|
|
120
|
+
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
152
123
|
resolve: {
|
|
153
|
-
// dedupe: ['quasar', '@quasar/extras'],
|
|
154
124
|
alias: [
|
|
155
|
-
// {
|
|
156
|
-
// find: 'quasar/wrappers',
|
|
157
|
-
// replacement: new URL('quasar-wrappers.ts', urls?.cli).pathname
|
|
158
|
-
// },
|
|
159
|
-
// {
|
|
160
|
-
// find: 'quasar/vue-plugin',
|
|
161
|
-
// replacement: new URL(
|
|
162
|
-
// 'src/vue-plugin.js',
|
|
163
|
-
// urls?.packages?.quasar
|
|
164
|
-
// ).pathname
|
|
165
|
-
// },
|
|
166
|
-
// {
|
|
167
|
-
// find: 'quasar/plugins',
|
|
168
|
-
// replacement: new URL('src/plugins.js', urls?.packages?.quasar)
|
|
169
|
-
// .pathname
|
|
170
|
-
// },
|
|
171
|
-
// {
|
|
172
|
-
// find: 'quasar/components',
|
|
173
|
-
// replacement: new URL(
|
|
174
|
-
// 'src/components.js',
|
|
175
|
-
// urls?.packages?.quasar
|
|
176
|
-
// ).pathname
|
|
177
|
-
// },
|
|
178
|
-
// {
|
|
179
|
-
// find: 'quasar/composables',
|
|
180
|
-
// replacement: new URL(
|
|
181
|
-
// 'src/composables.js',
|
|
182
|
-
// urls?.packages?.quasar
|
|
183
|
-
// ).pathname
|
|
184
|
-
// },
|
|
185
|
-
// {
|
|
186
|
-
// find: 'quasar/directives',
|
|
187
|
-
// replacement: new URL(
|
|
188
|
-
// 'src/directives.js',
|
|
189
|
-
// urls?.packages?.quasar
|
|
190
|
-
// ).pathname
|
|
191
|
-
// },
|
|
192
125
|
{
|
|
193
126
|
find: 'quasar/src/',
|
|
194
127
|
replacement: new URL('./src/', config.vitrify.urls.packages.quasar).pathname
|
|
195
128
|
}
|
|
196
|
-
// {
|
|
197
|
-
// find: 'quasar',
|
|
198
|
-
// replacement: new URL(
|
|
199
|
-
// 'node_modules/quasar',
|
|
200
|
-
// config.vitrify?.urls?.app
|
|
201
|
-
// )
|
|
202
|
-
// }
|
|
203
|
-
// {
|
|
204
|
-
// find: new RegExp('^quasar$'),
|
|
205
|
-
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
206
|
-
// .pathname
|
|
207
|
-
// }
|
|
208
|
-
// {
|
|
209
|
-
// find: `@quasar/extras`,
|
|
210
|
-
// replacement: new URL('.', urls?.packages?.['@quasar/extras'])
|
|
211
|
-
// .pathname
|
|
212
|
-
// }
|
|
213
|
-
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
214
129
|
]
|
|
215
130
|
},
|
|
216
131
|
optimizeDeps: {
|
|
@@ -219,13 +134,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
219
134
|
define: {
|
|
220
135
|
__DEV__: process.env.NODE_ENV !== 'production' || true,
|
|
221
136
|
__QUASAR_VERSION__: `'${version}'`
|
|
222
|
-
// __QUASAR_SSR__: !!ssr,
|
|
223
|
-
// // __QUASAR_SSR_SERVER__: ssr === 'server',
|
|
224
|
-
// __QUASAR_SSR_SERVER__: `import.meta.env.SSR`,
|
|
225
|
-
// // __QUASAR_SSR_CLIENT__: ssr === 'client',
|
|
226
|
-
// __QUASAR_SSR_CLIENT__: `!import.meta.env.SSR`,
|
|
227
|
-
// // __QUASAR_SSR_PWA__: ssr === 'client' && pwa
|
|
228
|
-
// __QUASAR_SSR_PWA__: pwa ? `!import.meta.env.SSR` : false
|
|
229
137
|
},
|
|
230
138
|
ssr: {
|
|
231
139
|
noExternal: ['quasar']
|
package/dist/types/bin/dev.d.ts
CHANGED
|
@@ -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;
|
|
@@ -22,7 +21,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
|
|
|
22
21
|
publicDir?: URL;
|
|
23
22
|
}): Promise<{
|
|
24
23
|
server: Server;
|
|
25
|
-
config: Readonly<Omit<import("vite").UserConfig, "
|
|
24
|
+
config: Readonly<Omit<import("vite").UserConfig, "plugins" | "assetsInclude" | "optimizeDeps" | "worker"> & {
|
|
26
25
|
configFile: string | undefined;
|
|
27
26
|
configFileDependencies: string[];
|
|
28
27
|
inlineConfig: InlineConfig;
|
|
@@ -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
|
|
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,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { FastifyInstance } from 'fastify';
|
|
3
|
-
import type { OnRenderedHook
|
|
3
|
+
import type { OnRenderedHook } from '../../vitrify-config.js';
|
|
4
4
|
import type { FastifyCsrPlugin } from './fastify-csr-plugin.js';
|
|
5
5
|
import type { FastifySsrPlugin } from './fastify-ssr-plugin.js';
|
|
6
6
|
export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, vitrifyDir, mode }: {
|
|
7
|
-
onSetup:
|
|
7
|
+
onSetup: ((fastify: FastifyInstance) => void)[];
|
|
8
8
|
appDir: URL;
|
|
9
9
|
baseUrl?: string | undefined;
|
|
10
10
|
fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin;
|
|
@@ -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.
|
|
3
|
+
"version": "0.7.2",
|
|
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.
|
|
61
|
-
"@quasar/extras": "^1.
|
|
62
|
-
"@vitejs/plugin-vue": "^3.0.
|
|
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.
|
|
69
|
-
"fastify": "^4.
|
|
68
|
+
"esbuild": "^0.14.53",
|
|
69
|
+
"fastify": "^4.3.0",
|
|
70
70
|
"glob": "^8.0.3",
|
|
71
|
-
"happy-dom": "^6.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.
|
|
76
|
-
"sass": "1.
|
|
77
|
-
"ts-node": "^10.
|
|
78
|
-
"unplugin-vue-components": "^0.
|
|
79
|
-
"vite": "3.0.
|
|
80
|
-
"vitest": "^0.
|
|
75
|
+
"rollup-plugin-visualizer": "^5.7.1",
|
|
76
|
+
"sass": "1.54.2",
|
|
77
|
+
"ts-node": "^10.9.1",
|
|
78
|
+
"unplugin-vue-components": "^0.22.0",
|
|
79
|
+
"vite": "^3.0.4",
|
|
80
|
+
"vitest": "^0.20.3"
|
|
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.
|
|
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.
|
|
90
|
-
"rollup": "^2.
|
|
89
|
+
"quasar": "^2.7.7",
|
|
90
|
+
"rollup": "^2.77.2",
|
|
91
91
|
"typescript": "^4.7.4",
|
|
92
92
|
"vue": "^3.2.37",
|
|
93
|
-
"vue-router": "^4.1.
|
|
93
|
+
"vue-router": "^4.1.3"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
|
-
"@fastify/static": "^6.
|
|
97
|
-
"fastify": "^4.
|
|
98
|
-
"quasar": "^2.7.
|
|
96
|
+
"@fastify/static": "^6.5.0",
|
|
97
|
+
"fastify": "^4.3.0",
|
|
98
|
+
"quasar": "^2.7.7",
|
|
99
99
|
"vue": "^3.2.37",
|
|
100
|
-
"vue-router": "^4.1.
|
|
100
|
+
"vue-router": "^4.1.3"
|
|
101
101
|
},
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public",
|
package/src/node/bin/dev.ts
CHANGED
|
@@ -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 {
|
|
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,12 @@ 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))
|
|
142
141
|
const app = fastify({
|
|
143
142
|
logger: false,
|
|
144
|
-
https: vite.config.server.https
|
|
145
|
-
|
|
143
|
+
https: vite.config.server.https,
|
|
144
|
+
...vitrifyConfig.vitrify?.ssr?.fastify
|
|
145
|
+
} as FastifyServerOptions)
|
|
146
146
|
if (process.env) process.env.MODE = 'development'
|
|
147
147
|
if (setup) {
|
|
148
148
|
await setup({
|
|
@@ -30,9 +30,6 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
30
30
|
options,
|
|
31
31
|
done
|
|
32
32
|
) => {
|
|
33
|
-
options.vitrifyDir =
|
|
34
|
-
options.vitrifyDir || (await import('vitrify')).vitrifyDir
|
|
35
|
-
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir)
|
|
36
33
|
options.baseUrl = options.baseUrl || '/'
|
|
37
34
|
options.mode = options.mode || process.env.MODE || import.meta.env.MODE
|
|
38
35
|
options.appDir = options.appDir || new URL('../../..', import.meta.url)
|
|
@@ -43,6 +40,9 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
43
40
|
)
|
|
44
41
|
throw new Error('baseUrl should start and end with a /')
|
|
45
42
|
if (options.mode === 'development') {
|
|
43
|
+
options.vitrifyDir =
|
|
44
|
+
options.vitrifyDir || (await import('vitrify')).vitrifyDir
|
|
45
|
+
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir)
|
|
46
46
|
// if (!options.vitrifyDir)
|
|
47
47
|
// throw new Error('Option vitrifyDir cannot be undefined')
|
|
48
48
|
// if (!options.vite) throw new Error('Option vite cannot be undefined')
|
|
@@ -15,7 +15,7 @@ export const createApp = ({
|
|
|
15
15
|
vitrifyDir,
|
|
16
16
|
mode
|
|
17
17
|
}: {
|
|
18
|
-
onSetup:
|
|
18
|
+
onSetup: ((fastify: FastifyInstance) => void)[]
|
|
19
19
|
appDir: URL
|
|
20
20
|
baseUrl?: string
|
|
21
21
|
fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin
|
|
@@ -35,11 +35,11 @@ export const createApp = ({
|
|
|
35
35
|
mode
|
|
36
36
|
})
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
if (onSetup?.length) {
|
|
39
|
+
for (const setup of onSetup) {
|
|
40
|
+
setup(app)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
43
|
|
|
44
44
|
return app
|
|
45
45
|
}
|
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 {
|
|
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)) {
|
|
@@ -261,7 +254,7 @@ export const baseConfig = async ({
|
|
|
261
254
|
let onRenderedHooks: OnRenderedHook[]
|
|
262
255
|
let onMountedHooks: OnMountedHook[]
|
|
263
256
|
let onSetupFiles: OnSetupFile[]
|
|
264
|
-
let globalCss: string[]
|
|
257
|
+
let globalCss: string[] = []
|
|
265
258
|
let staticImports: StaticImports
|
|
266
259
|
let sassVariables: Record<string, string>
|
|
267
260
|
let additionalData: string[]
|
|
@@ -275,32 +268,12 @@ 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',
|
|
302
275
|
enforce: 'post',
|
|
303
|
-
config:
|
|
276
|
+
config: (config: VitrifyConfig, env) => {
|
|
304
277
|
onBootHooks = config.vitrify?.hooks?.onBoot || []
|
|
305
278
|
onRenderedHooks = config.vitrify?.hooks?.onRendered || []
|
|
306
279
|
onMountedHooks = config.vitrify?.hooks?.onMounted || []
|
|
@@ -310,22 +283,7 @@ export const baseConfig = async ({
|
|
|
310
283
|
sassVariables = config.vitrify?.sass?.variables || {}
|
|
311
284
|
globalSass = config.vitrify?.sass?.global || []
|
|
312
285
|
additionalData = config.vitrify?.sass?.additionalData || []
|
|
313
|
-
|
|
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
|
-
}
|
|
286
|
+
return
|
|
329
287
|
},
|
|
330
288
|
configureServer(server) {
|
|
331
289
|
server.middlewares.use('/', (req, res, next) => {
|
|
@@ -335,8 +293,7 @@ export const baseConfig = async ({
|
|
|
335
293
|
},
|
|
336
294
|
configResolved: (config) => {
|
|
337
295
|
if (process.env.DEBUG) {
|
|
338
|
-
console.log(config
|
|
339
|
-
console.log(config.optimizeDeps)
|
|
296
|
+
console.log(config)
|
|
340
297
|
}
|
|
341
298
|
},
|
|
342
299
|
resolveId(id) {
|
|
@@ -363,30 +320,20 @@ export const baseConfig = async ({
|
|
|
363
320
|
.join(', ')}]
|
|
364
321
|
export const onSetup = []
|
|
365
322
|
${onSetupFiles
|
|
366
|
-
.map(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
.replaceAll('/', '')
|
|
374
|
-
.replaceAll('.', '')})`
|
|
375
|
-
)
|
|
323
|
+
.map((url, index) => {
|
|
324
|
+
const varName = url.pathname
|
|
325
|
+
.replaceAll('/', '')
|
|
326
|
+
.replaceAll('.', '')
|
|
327
|
+
.replaceAll('-', '')
|
|
328
|
+
return `import ${varName} from '${url.pathname}'; onSetup.push(${varName})`
|
|
329
|
+
})
|
|
376
330
|
.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
331
|
} else if (id === 'virtual:static-imports') {
|
|
386
332
|
return `${Object.entries(staticImports)
|
|
387
|
-
.map(
|
|
388
|
-
|
|
389
|
-
|
|
333
|
+
.map(([key, value]) => {
|
|
334
|
+
const deduped = [...new Set(value)]
|
|
335
|
+
return `export { ${deduped.join(',')} } from '${key}';`
|
|
336
|
+
})
|
|
390
337
|
.join('\n')}`
|
|
391
338
|
} else if (id === 'vitrify.sass') {
|
|
392
339
|
return [
|
|
@@ -408,16 +355,16 @@ export const baseConfig = async ({
|
|
|
408
355
|
plugins.unshift({
|
|
409
356
|
name: 'html-transform',
|
|
410
357
|
enforce: 'pre',
|
|
411
|
-
transform: (code, id) => {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
// do not remove, required for additionalData import
|
|
417
|
-
</style>`
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
},
|
|
358
|
+
// transform: (code, id) => {
|
|
359
|
+
// if (id.endsWith('App.vue')) {
|
|
360
|
+
// code =
|
|
361
|
+
// code +
|
|
362
|
+
// `<style lang="sass">
|
|
363
|
+
// // do not remove, required for additionalData import
|
|
364
|
+
// </style>`
|
|
365
|
+
// }
|
|
366
|
+
// return code
|
|
367
|
+
// },
|
|
421
368
|
transformIndexHtml: {
|
|
422
369
|
enforce: 'pre',
|
|
423
370
|
transform: (html) => {
|
|
@@ -449,6 +396,7 @@ export const baseConfig = async ({
|
|
|
449
396
|
config: (config: VitrifyConfig, env) => {
|
|
450
397
|
if (config.vitrify?.productName)
|
|
451
398
|
productName = config.vitrify?.productName
|
|
399
|
+
return
|
|
452
400
|
},
|
|
453
401
|
transformIndexHtml: {
|
|
454
402
|
enforce: 'post',
|
|
@@ -479,10 +427,6 @@ export const baseConfig = async ({
|
|
|
479
427
|
packageUrls['vue']
|
|
480
428
|
).pathname
|
|
481
429
|
},
|
|
482
|
-
// {
|
|
483
|
-
// find: new RegExp('^vue/server-renderer$'),
|
|
484
|
-
// replacement: 'vue/server-renderer/index.mjs'
|
|
485
|
-
// },
|
|
486
430
|
{
|
|
487
431
|
find: new RegExp('^vue-router$'),
|
|
488
432
|
replacement: new URL(
|
|
@@ -490,9 +434,6 @@ export const baseConfig = async ({
|
|
|
490
434
|
packageUrls['vue-router']
|
|
491
435
|
).pathname
|
|
492
436
|
}
|
|
493
|
-
// { find: 'vue', replacement: packageUrls['vue'].pathname },
|
|
494
|
-
// { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
|
|
495
|
-
// { find: 'vitrify', replacement: cliDir.pathname }
|
|
496
437
|
]
|
|
497
438
|
if (mode === 'development' && vitrifyConfig.vitrify?.dev?.alias)
|
|
498
439
|
alias.push(...vitrifyConfig.vitrify.dev.alias)
|
|
@@ -519,25 +460,16 @@ export const baseConfig = async ({
|
|
|
519
460
|
],
|
|
520
461
|
external,
|
|
521
462
|
output: {
|
|
522
|
-
minifyInternalExports:
|
|
463
|
+
minifyInternalExports: false,
|
|
523
464
|
entryFileNames: '[name].mjs',
|
|
524
465
|
chunkFileNames: '[name].mjs',
|
|
525
466
|
format: 'es',
|
|
526
467
|
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
468
|
}
|
|
536
469
|
}
|
|
537
470
|
// Create a SSR bundle
|
|
538
471
|
noExternal = [
|
|
539
472
|
new RegExp(`^(?!(${[...builtinModules, ...serverModules].join('|')}))`)
|
|
540
|
-
// new RegExp(`^(?!.*(${[...builtinModules, ...serverModules].join('|')}))`)
|
|
541
473
|
]
|
|
542
474
|
} else if (ssr === 'fastify') {
|
|
543
475
|
rollupOptions = {
|
|
@@ -550,14 +482,6 @@ export const baseConfig = async ({
|
|
|
550
482
|
chunkFileNames: '[name].mjs',
|
|
551
483
|
format: 'es',
|
|
552
484
|
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
485
|
}
|
|
562
486
|
}
|
|
563
487
|
// Create a SSR bundle
|
|
@@ -567,13 +491,9 @@ export const baseConfig = async ({
|
|
|
567
491
|
} else {
|
|
568
492
|
rollupOptions = {
|
|
569
493
|
...rollupOptions,
|
|
570
|
-
// input: [
|
|
571
|
-
// new URL('index.html', frameworkDir).pathname
|
|
572
|
-
// // new URL('csr/server.ts', frameworkDir).pathname
|
|
573
|
-
// ],
|
|
574
494
|
external,
|
|
575
495
|
output: {
|
|
576
|
-
minifyInternalExports:
|
|
496
|
+
minifyInternalExports: false,
|
|
577
497
|
entryFileNames: '[name].mjs',
|
|
578
498
|
chunkFileNames: '[name].mjs',
|
|
579
499
|
format: 'es',
|
|
@@ -583,7 +503,6 @@ export const baseConfig = async ({
|
|
|
583
503
|
}
|
|
584
504
|
|
|
585
505
|
const config = {
|
|
586
|
-
// root: ssr === 'fastify' ? appDir.pathname : frameworkDir.pathname,
|
|
587
506
|
root: appDir.pathname,
|
|
588
507
|
publicDir: publicDir.pathname,
|
|
589
508
|
base,
|
|
@@ -611,33 +530,6 @@ export const baseConfig = async ({
|
|
|
611
530
|
ssr: ssr === 'server' || ssr === 'fastify' ? true : false,
|
|
612
531
|
ssrManifest: ssr === 'client' || ssr === 'ssg',
|
|
613
532
|
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
533
|
},
|
|
642
534
|
ssr: {
|
|
643
535
|
// Create a SSR bundle
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import { readFileSync } from 'fs'
|
|
2
1
|
import type { Plugin } from 'vite'
|
|
3
2
|
import { resolvePackageData } from 'vite'
|
|
4
3
|
import Components from 'unplugin-vue-components/vite'
|
|
5
|
-
// import { prepareQuasarConf } from './quasar-conf-file.js'
|
|
6
4
|
import type {
|
|
7
|
-
BootFunction,
|
|
8
5
|
OnBootHook,
|
|
9
6
|
OnMountedHook,
|
|
10
7
|
VitrifyConfig
|
|
11
8
|
} from '../vitrify-config.js'
|
|
12
|
-
// import { quasarDir as defaultQuasarDir } from '../app-urls.js'
|
|
13
|
-
// import { QuasarResolver } from '../resolver.js';
|
|
14
9
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers'
|
|
15
10
|
import type { VitrifyPlugin } from './index.js'
|
|
16
|
-
import { getPkgJsonDir, resolve } from '../app-urls.js'
|
|
17
|
-
|
|
18
|
-
// import { resolve } from 'import-meta-resolve'
|
|
19
|
-
|
|
20
11
|
export interface QuasarConf {
|
|
21
12
|
ctx: Record<string, any>
|
|
22
13
|
css: string[]
|
|
@@ -152,7 +143,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
152
143
|
const directives = await import('virtual:quasar-directives')
|
|
153
144
|
// @ts-ignore
|
|
154
145
|
const { default: lang } = await import('virtual:quasar-lang')
|
|
155
|
-
|
|
146
|
+
|
|
156
147
|
app.use(
|
|
157
148
|
staticImports?.Quasar,
|
|
158
149
|
{
|
|
@@ -165,44 +156,10 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
165
156
|
}
|
|
166
157
|
]
|
|
167
158
|
|
|
168
|
-
return {
|
|
169
|
-
vitrify: {
|
|
170
|
-
urls,
|
|
171
|
-
globalCss,
|
|
172
|
-
staticImports: {
|
|
173
|
-
quasar: ['Quasar']
|
|
174
|
-
},
|
|
175
|
-
hooks: {
|
|
176
|
-
onBoot: onBootHooks,
|
|
177
|
-
onMounted: onMountedHooks,
|
|
178
|
-
onRendered: [injectSsrContext]
|
|
179
|
-
},
|
|
180
|
-
sass: {
|
|
181
|
-
global: ['quasar/src/css/index.sass']
|
|
182
|
-
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: 'vite-plugin-quasar',
|
|
190
|
-
enforce: 'post',
|
|
191
|
-
config: async (config: VitrifyConfig, env) => {
|
|
192
|
-
const { quasar, vitrify: { urls } = {} } = config
|
|
193
159
|
if (quasar) quasarConf = quasar
|
|
194
160
|
if (!quasarConf.framework.lang && config.vitrify?.lang)
|
|
195
161
|
quasarConf.framework.lang = config.vitrify.lang
|
|
196
|
-
|
|
197
|
-
// 'package.json',
|
|
198
|
-
// urls?.packages?.quasar
|
|
199
|
-
// ).pathname
|
|
200
|
-
// const { version } = JSON.parse(
|
|
201
|
-
// readFileSync(quasarPkgJsonPath, { encoding: 'utf-8' })
|
|
202
|
-
// )
|
|
203
|
-
// const { version } = await import('quasar/package.json', {
|
|
204
|
-
// assert: { type: 'json' }
|
|
205
|
-
// })
|
|
162
|
+
|
|
206
163
|
/**
|
|
207
164
|
* Importing package.json is problematic
|
|
208
165
|
*/
|
|
@@ -220,53 +177,24 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
220
177
|
}
|
|
221
178
|
|
|
222
179
|
return {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
180
|
+
vitrify: {
|
|
181
|
+
urls,
|
|
182
|
+
globalCss,
|
|
183
|
+
staticImports: {
|
|
184
|
+
quasar: ['Quasar']
|
|
185
|
+
},
|
|
186
|
+
hooks: {
|
|
187
|
+
onBoot: onBootHooks,
|
|
188
|
+
onMounted: onMountedHooks,
|
|
189
|
+
onRendered: [injectSsrContext]
|
|
190
|
+
},
|
|
191
|
+
sass: {
|
|
192
|
+
global: ['quasar/src/css/index.sass']
|
|
193
|
+
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
194
|
+
}
|
|
195
|
+
},
|
|
230
196
|
resolve: {
|
|
231
|
-
// dedupe: ['quasar', '@quasar/extras'],
|
|
232
197
|
alias: [
|
|
233
|
-
// {
|
|
234
|
-
// find: 'quasar/wrappers',
|
|
235
|
-
// replacement: new URL('quasar-wrappers.ts', urls?.cli).pathname
|
|
236
|
-
// },
|
|
237
|
-
// {
|
|
238
|
-
// find: 'quasar/vue-plugin',
|
|
239
|
-
// replacement: new URL(
|
|
240
|
-
// 'src/vue-plugin.js',
|
|
241
|
-
// urls?.packages?.quasar
|
|
242
|
-
// ).pathname
|
|
243
|
-
// },
|
|
244
|
-
// {
|
|
245
|
-
// find: 'quasar/plugins',
|
|
246
|
-
// replacement: new URL('src/plugins.js', urls?.packages?.quasar)
|
|
247
|
-
// .pathname
|
|
248
|
-
// },
|
|
249
|
-
// {
|
|
250
|
-
// find: 'quasar/components',
|
|
251
|
-
// replacement: new URL(
|
|
252
|
-
// 'src/components.js',
|
|
253
|
-
// urls?.packages?.quasar
|
|
254
|
-
// ).pathname
|
|
255
|
-
// },
|
|
256
|
-
// {
|
|
257
|
-
// find: 'quasar/composables',
|
|
258
|
-
// replacement: new URL(
|
|
259
|
-
// 'src/composables.js',
|
|
260
|
-
// urls?.packages?.quasar
|
|
261
|
-
// ).pathname
|
|
262
|
-
// },
|
|
263
|
-
// {
|
|
264
|
-
// find: 'quasar/directives',
|
|
265
|
-
// replacement: new URL(
|
|
266
|
-
// 'src/directives.js',
|
|
267
|
-
// urls?.packages?.quasar
|
|
268
|
-
// ).pathname
|
|
269
|
-
// },
|
|
270
198
|
{
|
|
271
199
|
find: 'quasar/src/',
|
|
272
200
|
replacement: new URL(
|
|
@@ -274,24 +202,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
274
202
|
config.vitrify!.urls!.packages!.quasar
|
|
275
203
|
).pathname
|
|
276
204
|
}
|
|
277
|
-
// {
|
|
278
|
-
// find: 'quasar',
|
|
279
|
-
// replacement: new URL(
|
|
280
|
-
// 'node_modules/quasar',
|
|
281
|
-
// config.vitrify?.urls?.app
|
|
282
|
-
// )
|
|
283
|
-
// }
|
|
284
|
-
// {
|
|
285
|
-
// find: new RegExp('^quasar$'),
|
|
286
|
-
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
287
|
-
// .pathname
|
|
288
|
-
// }
|
|
289
|
-
// {
|
|
290
|
-
// find: `@quasar/extras`,
|
|
291
|
-
// replacement: new URL('.', urls?.packages?.['@quasar/extras'])
|
|
292
|
-
// .pathname
|
|
293
|
-
// }
|
|
294
|
-
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
295
205
|
]
|
|
296
206
|
},
|
|
297
207
|
optimizeDeps: {
|
|
@@ -300,13 +210,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
300
210
|
define: {
|
|
301
211
|
__DEV__: process.env.NODE_ENV !== 'production' || true,
|
|
302
212
|
__QUASAR_VERSION__: `'${version}'`
|
|
303
|
-
// __QUASAR_SSR__: !!ssr,
|
|
304
|
-
// // __QUASAR_SSR_SERVER__: ssr === 'server',
|
|
305
|
-
// __QUASAR_SSR_SERVER__: `import.meta.env.SSR`,
|
|
306
|
-
// // __QUASAR_SSR_CLIENT__: ssr === 'client',
|
|
307
|
-
// __QUASAR_SSR_CLIENT__: `!import.meta.env.SSR`,
|
|
308
|
-
// // __QUASAR_SSR_PWA__: ssr === 'client' && pwa
|
|
309
|
-
// __QUASAR_SSR_PWA__: pwa ? `!import.meta.env.SSR` : false
|
|
310
213
|
},
|
|
311
214
|
ssr: {
|
|
312
215
|
noExternal: ['quasar']
|
|
@@ -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
|