vitrify 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-urls.js +1 -1
- package/dist/bin/cli.js +11 -4
- package/dist/bin/dev.js +24 -37
- package/dist/frameworks/vue/fastify-ssr-plugin.js +45 -6
- package/dist/frameworks/vue/prerender.js +1 -5
- package/dist/frameworks/vue/server.js +3 -0
- package/dist/index.js +71 -95
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/quasar/index.js +227 -0
- package/dist/types/app-urls.d.ts +1 -1
- package/dist/types/frameworks/vue/fastify-ssr-plugin.d.ts +11 -1
- package/dist/types/frameworks/vue/prerender.d.ts +6 -4
- package/dist/types/plugins/index.d.ts +12 -2
- package/dist/types/plugins/{quasar.d.ts → quasar/index.d.ts} +3 -3
- package/dist/types/vitrify-config.d.ts +15 -2
- package/package.json +20 -19
- package/src/node/app-urls.ts +2 -2
- package/src/node/bin/cli.ts +13 -6
- package/src/node/bin/dev.ts +24 -38
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +64 -27
- package/src/node/frameworks/vue/prerender.ts +9 -10
- package/src/node/frameworks/vue/server.ts +3 -0
- package/src/node/index.ts +103 -128
- package/src/node/plugins/index.ts +19 -3
- package/src/node/plugins/quasar/index.ts +320 -0
- package/src/node/vitrify-config.ts +17 -3
- package/src/vite/fastify/server.ts +3 -0
- package/src/vite/vue/ssr/fastify-ssr-plugin.ts +3 -2
- package/dist/plugins/quasar.js +0 -217
- package/src/node/plugins/quasar.ts +0 -307
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import type { Plugin } from 'vite'
|
|
2
|
+
import { fileURLToPath } from 'url'
|
|
3
|
+
import type {
|
|
4
|
+
OnBootHook,
|
|
5
|
+
OnMountedHook,
|
|
6
|
+
VitrifyConfig
|
|
7
|
+
} from '../../vitrify-config.js'
|
|
8
|
+
import type { VitrifyPlugin } from '../index.js'
|
|
9
|
+
import { findDepPkgJsonPath } from 'vitefu'
|
|
10
|
+
import {
|
|
11
|
+
type QuasarFonts,
|
|
12
|
+
type QuasarComponents,
|
|
13
|
+
type QuasarDirectives,
|
|
14
|
+
type QuasarIconSets,
|
|
15
|
+
type QuasarPlugins,
|
|
16
|
+
type GlobalQuasarIconMapFn,
|
|
17
|
+
type QuasarIconSet
|
|
18
|
+
} from 'quasar'
|
|
19
|
+
import { QuasarResolver } from 'unplugin-vue-components/resolvers'
|
|
20
|
+
|
|
21
|
+
export interface QuasarPluginOptions {
|
|
22
|
+
framework: {
|
|
23
|
+
components?: (keyof QuasarComponents)[]
|
|
24
|
+
directives?: (keyof QuasarDirectives)[]
|
|
25
|
+
plugins?: (keyof QuasarPlugins)[]
|
|
26
|
+
lang?: string
|
|
27
|
+
iconSet?: QuasarIconSets | QuasarIconSet
|
|
28
|
+
iconMapFn?: GlobalQuasarIconMapFn
|
|
29
|
+
}
|
|
30
|
+
extras?: (QuasarIconSets | QuasarFonts)[]
|
|
31
|
+
disableSass?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const injectSsrContext = (
|
|
35
|
+
html: string,
|
|
36
|
+
ssrContext: Record<string, any>
|
|
37
|
+
) =>
|
|
38
|
+
html
|
|
39
|
+
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
40
|
+
let matches
|
|
41
|
+
|
|
42
|
+
matches = found.match(/\sdir\s*=\s*['"]([^'"]*)['"]/i)
|
|
43
|
+
if (matches) {
|
|
44
|
+
start = start.replace(matches[0], '')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
matches = found.match(/\slang\s*=\s*['"]([^'"]*)['"]/i)
|
|
48
|
+
if (matches) {
|
|
49
|
+
start = start.replace(matches[0], '')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return `${start} ${ssrContext._meta.htmlAttrs || ''} ${end}`
|
|
53
|
+
})
|
|
54
|
+
.replace(
|
|
55
|
+
/(<head[^>]*)(>)/i,
|
|
56
|
+
(_, start, end) => `${start}${end}${ssrContext._meta.headTags || ''}`
|
|
57
|
+
)
|
|
58
|
+
.replace(
|
|
59
|
+
/(<\/head>)/i,
|
|
60
|
+
(_, tag) =>
|
|
61
|
+
`${ssrContext._meta.resourceStyles || ''}${
|
|
62
|
+
ssrContext._meta.endingHeadTags || ''
|
|
63
|
+
}${tag}`
|
|
64
|
+
)
|
|
65
|
+
.replace(/(<body[^>]*)(>)/i, (found, start, end) => {
|
|
66
|
+
let classes = ssrContext._meta.bodyClasses || ''
|
|
67
|
+
|
|
68
|
+
const matches = found.match(/\sclass\s*=\s*['"]([^'"]*)['"]/i)
|
|
69
|
+
|
|
70
|
+
if (matches) {
|
|
71
|
+
if (matches[1].length > 0) {
|
|
72
|
+
classes += ` ${matches[1]}`
|
|
73
|
+
}
|
|
74
|
+
start = start.replace(matches[0], '')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return `${start} class="${classes.trim()}" ${
|
|
78
|
+
ssrContext._meta.bodyAttrs || ''
|
|
79
|
+
}${end}${ssrContext._meta.bodyTags || ''}`
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export const QuasarPlugin: VitrifyPlugin<QuasarPluginOptions> = async ({
|
|
83
|
+
ssr = false,
|
|
84
|
+
pwa = false,
|
|
85
|
+
options
|
|
86
|
+
}) => {
|
|
87
|
+
let plugins: string[] = []
|
|
88
|
+
const quasarConf: QuasarPluginOptions = options
|
|
89
|
+
return {
|
|
90
|
+
plugins: [
|
|
91
|
+
{
|
|
92
|
+
name: 'vite-plugin-quasar-transform',
|
|
93
|
+
enforce: 'pre',
|
|
94
|
+
transform: (code, id, options) => {
|
|
95
|
+
code = code
|
|
96
|
+
.replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
|
|
97
|
+
.replaceAll(
|
|
98
|
+
'__QUASAR_SSR_SERVER__',
|
|
99
|
+
ssr ? '(import.meta.env.SSR === true)' : 'false'
|
|
100
|
+
)
|
|
101
|
+
.replaceAll(
|
|
102
|
+
'__QUASAR_SSR_CLIENT__',
|
|
103
|
+
ssr ? '(import.meta.env.SSR === false)' : 'false'
|
|
104
|
+
)
|
|
105
|
+
.replaceAll(
|
|
106
|
+
'__QUASAR_SSR_PWA__',
|
|
107
|
+
ssr && pwa ? '(import.meta.env.SSR === false)' : 'false'
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
return code
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'vite-plugin-quasar-setup',
|
|
115
|
+
enforce: 'pre',
|
|
116
|
+
config: async (config: VitrifyConfig, env): Promise<VitrifyConfig> => {
|
|
117
|
+
const { vitrify: { urls } = {} } = config
|
|
118
|
+
|
|
119
|
+
// if (quasar) quasarConf = quasar
|
|
120
|
+
if (!quasarConf.framework.lang && config.vitrify?.lang)
|
|
121
|
+
quasarConf.framework.lang = config.vitrify.lang
|
|
122
|
+
|
|
123
|
+
const globalCss = quasarConf?.extras?.map(
|
|
124
|
+
(extra) => `@quasar/extras/${extra}/${extra}.css`
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
const localPackages = ['@quasar/extras', 'quasar']
|
|
128
|
+
// const localPackages: string[] = []
|
|
129
|
+
await (async () => {
|
|
130
|
+
for (const val of localPackages) {
|
|
131
|
+
const pkgDir = await findDepPkgJsonPath(
|
|
132
|
+
val,
|
|
133
|
+
fileURLToPath(config.vitrify!.urls!.app!)
|
|
134
|
+
)
|
|
135
|
+
if (pkgDir) urls!.packages![val] = new URL(`file://${pkgDir}`)
|
|
136
|
+
}
|
|
137
|
+
})()
|
|
138
|
+
|
|
139
|
+
const onMountedHooks: OnMountedHook[] = [
|
|
140
|
+
async (instance) => {
|
|
141
|
+
const {
|
|
142
|
+
proxy: { $q }
|
|
143
|
+
} = instance
|
|
144
|
+
if ($q.onSSRHydrated !== void 0) $q.onSSRHydrated()
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
const onBootHooks: OnBootHook[] = [
|
|
149
|
+
async ({ app, ssrContext, staticImports }) => {
|
|
150
|
+
// @ts-expect-error undefined
|
|
151
|
+
const quasarPlugins = await import('virtual:quasar-plugins')
|
|
152
|
+
// @ts-expect-error undefined
|
|
153
|
+
const directives = await import('virtual:quasar-directives')
|
|
154
|
+
// @ts-expect-error undefined
|
|
155
|
+
const { default: lang } = await import('virtual:quasar-lang')
|
|
156
|
+
const { default: iconSet } = await import(
|
|
157
|
+
// @ts-expect-error undefined
|
|
158
|
+
'virtual:quasar-iconSet'
|
|
159
|
+
)
|
|
160
|
+
const { default: iconMapFn } = await import(
|
|
161
|
+
// @ts-expect-error undefined
|
|
162
|
+
'virtual:quasar-iconMapFn'
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
app.use(
|
|
166
|
+
staticImports?.Quasar,
|
|
167
|
+
{
|
|
168
|
+
plugins: quasarPlugins,
|
|
169
|
+
directives,
|
|
170
|
+
lang,
|
|
171
|
+
iconSet,
|
|
172
|
+
config: {
|
|
173
|
+
iconMapFn
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
ssrContext
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Importing package.json is problematic
|
|
183
|
+
*/
|
|
184
|
+
const version = '?'
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* All components should have been auto-imported
|
|
188
|
+
*/
|
|
189
|
+
if (quasarConf?.framework?.plugins) {
|
|
190
|
+
if (!quasarConf.framework) quasarConf.framework = {}
|
|
191
|
+
quasarConf.framework.plugins = [
|
|
192
|
+
...new Set(quasarConf.framework.plugins)
|
|
193
|
+
]
|
|
194
|
+
plugins = quasarConf?.framework.plugins
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
vitrify: {
|
|
199
|
+
urls,
|
|
200
|
+
globalCss,
|
|
201
|
+
staticImports: {
|
|
202
|
+
quasar: ['Quasar']
|
|
203
|
+
},
|
|
204
|
+
hooks: {
|
|
205
|
+
onBoot: onBootHooks,
|
|
206
|
+
onMounted: onMountedHooks,
|
|
207
|
+
onRendered: [injectSsrContext]
|
|
208
|
+
},
|
|
209
|
+
sass: quasarConf.disableSass
|
|
210
|
+
? undefined
|
|
211
|
+
: {
|
|
212
|
+
global: ['quasar/src/css/index.sass']
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
resolve: {
|
|
216
|
+
alias: [
|
|
217
|
+
{
|
|
218
|
+
find: 'quasar/src/',
|
|
219
|
+
replacement: fileURLToPath(
|
|
220
|
+
new URL('./src/', config.vitrify!.urls!.packages!.quasar)
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
optimizeDeps: {
|
|
226
|
+
exclude: ['quasar']
|
|
227
|
+
},
|
|
228
|
+
define: {
|
|
229
|
+
__DEV__: process.env.NODE_ENV !== 'production' || true,
|
|
230
|
+
__QUASAR_VERSION__: `'${version}'`
|
|
231
|
+
},
|
|
232
|
+
ssr: {
|
|
233
|
+
noExternal: ['quasar']
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: 'quasar-virtual-modules',
|
|
240
|
+
enforce: 'pre',
|
|
241
|
+
config: async (config, env) => ({
|
|
242
|
+
resolve: {
|
|
243
|
+
alias: [
|
|
244
|
+
{
|
|
245
|
+
find: new RegExp('^quasar$'),
|
|
246
|
+
replacement: 'virtual:quasar'
|
|
247
|
+
}
|
|
248
|
+
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
}),
|
|
252
|
+
resolveId(id) {
|
|
253
|
+
switch (id) {
|
|
254
|
+
case 'virtual:quasar-plugins':
|
|
255
|
+
return 'virtual:quasar-plugins'
|
|
256
|
+
case 'virtual:quasar-directives':
|
|
257
|
+
return 'virtual:quasar-directives'
|
|
258
|
+
case 'virtual:quasar-lang':
|
|
259
|
+
return 'virtual:quasar-lang'
|
|
260
|
+
case 'virtual:quasar-iconSet':
|
|
261
|
+
return 'virtual:quasar-iconSet'
|
|
262
|
+
case 'virtual:quasar-iconMapFn':
|
|
263
|
+
return 'virtual:quasar-iconMapFn'
|
|
264
|
+
case 'virtual:quasar':
|
|
265
|
+
return { id: 'virtual:quasar', moduleSideEffects: false }
|
|
266
|
+
default:
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
load(id) {
|
|
271
|
+
if (id === 'virtual:quasar-plugins') {
|
|
272
|
+
return `export { ${plugins.join(',')} } from 'quasar'`
|
|
273
|
+
} else if (id === 'virtual:quasar-directives') {
|
|
274
|
+
return `export * from 'quasar/src/directives.js'`
|
|
275
|
+
} else if (id === 'virtual:quasar-lang') {
|
|
276
|
+
return `import lang from 'quasar/lang/${
|
|
277
|
+
quasarConf?.framework?.lang || 'en-US'
|
|
278
|
+
}';
|
|
279
|
+
export default lang`
|
|
280
|
+
} else if (id === 'virtual:quasar-iconSet') {
|
|
281
|
+
return `${
|
|
282
|
+
typeof quasarConf.framework.iconSet === 'string'
|
|
283
|
+
? `import iconSet from 'quasar/icon-set/${
|
|
284
|
+
quasarConf?.framework.iconSet || 'material-icons'
|
|
285
|
+
}';
|
|
286
|
+
export default iconSet`
|
|
287
|
+
: `export default ${
|
|
288
|
+
quasarConf.framework.iconSet
|
|
289
|
+
? JSON.stringify(quasarConf.framework.iconSet)
|
|
290
|
+
: null
|
|
291
|
+
}`
|
|
292
|
+
}`
|
|
293
|
+
} else if (id === 'virtual:quasar-iconMapFn') {
|
|
294
|
+
return `export default ${
|
|
295
|
+
quasarConf?.framework.iconMapFn?.toString() ?? null
|
|
296
|
+
}`
|
|
297
|
+
} else if (id === 'virtual:quasar') {
|
|
298
|
+
return `export * from 'quasar/src/plugins.js';
|
|
299
|
+
export * from 'quasar/src/components.js';
|
|
300
|
+
export * from 'quasar/src/composables.js';
|
|
301
|
+
export * from 'quasar/src/directives.js';
|
|
302
|
+
export * from 'quasar/src/utils.js';
|
|
303
|
+
export * from 'quasar/src/composables.js';
|
|
304
|
+
export { default as Quasar } from 'quasar/src/install-quasar.js'`
|
|
305
|
+
}
|
|
306
|
+
return null
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
],
|
|
310
|
+
config: {
|
|
311
|
+
vitrify: {
|
|
312
|
+
unpluginVueComponents: {
|
|
313
|
+
resolvers: [QuasarResolver()]
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export default QuasarPlugin
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Alias, UserConfig as ViteUserConfig, ViteDevServer } from 'vite'
|
|
2
|
-
import type { QuasarConf } from './plugins/quasar.js'
|
|
3
2
|
import type { ComponentInternalInstance } from '@vue/runtime-core'
|
|
4
3
|
import type { FastifyInstance, FastifyServerOptions } from 'fastify'
|
|
5
4
|
import type { VitePWAOptions } from 'vite-plugin-pwa'
|
|
6
|
-
import {
|
|
5
|
+
import type { Options as unpluginVueComponentsOptions } from 'unplugin-vue-components'
|
|
7
6
|
import type { UserConfig as UnoCSSUserConfig } from '@unocss/core'
|
|
7
|
+
import { VitrifyPlugin } from './plugins/index.js'
|
|
8
8
|
|
|
9
9
|
export type BootFunction = ({
|
|
10
10
|
app,
|
|
@@ -43,9 +43,14 @@ export type OnSetupHook = (
|
|
|
43
43
|
}
|
|
44
44
|
) => any
|
|
45
45
|
export type OnSetupFile = URL
|
|
46
|
+
|
|
46
47
|
export interface VitrifyConfig extends ViteUserConfig {
|
|
47
48
|
vitrify?: {
|
|
48
49
|
lang?: string
|
|
50
|
+
/**
|
|
51
|
+
* Vitrify plugins
|
|
52
|
+
*/
|
|
53
|
+
plugins?: VitrifyPluginConfig[]
|
|
49
54
|
/**
|
|
50
55
|
* Global CSS imports
|
|
51
56
|
*/
|
|
@@ -118,8 +123,12 @@ export interface VitrifyConfig extends ViteUserConfig {
|
|
|
118
123
|
* UnoCSS Configuration
|
|
119
124
|
*/
|
|
120
125
|
unocss?: UnoCSSUserConfig
|
|
126
|
+
/**
|
|
127
|
+
* unplugin-vue-components configuration
|
|
128
|
+
*/
|
|
129
|
+
unpluginVueComponents?: unpluginVueComponentsOptions
|
|
121
130
|
}
|
|
122
|
-
quasar?: QuasarConf
|
|
131
|
+
// quasar?: QuasarConf
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
export type VitrifyCommands = 'build' | 'dev' | 'test'
|
|
@@ -135,4 +144,9 @@ export type VitrifyConfigAsync = ({
|
|
|
135
144
|
command: VitrifyCommands
|
|
136
145
|
}) => Promise<VitrifyConfig>
|
|
137
146
|
|
|
147
|
+
type VitrifyPluginConfig = {
|
|
148
|
+
plugin: VitrifyPlugin<any>
|
|
149
|
+
options: any
|
|
150
|
+
}
|
|
151
|
+
|
|
138
152
|
export const defineConfig = (config: VitrifyConfig) => config
|
package/dist/plugins/quasar.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'url';
|
|
2
|
-
import { findDepPkgJsonPath } from 'vitefu';
|
|
3
|
-
export const injectSsrContext = (html, ssrContext) => html
|
|
4
|
-
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
5
|
-
let matches;
|
|
6
|
-
matches = found.match(/\sdir\s*=\s*['"]([^'"]*)['"]/i);
|
|
7
|
-
if (matches) {
|
|
8
|
-
start = start.replace(matches[0], '');
|
|
9
|
-
}
|
|
10
|
-
matches = found.match(/\slang\s*=\s*['"]([^'"]*)['"]/i);
|
|
11
|
-
if (matches) {
|
|
12
|
-
start = start.replace(matches[0], '');
|
|
13
|
-
}
|
|
14
|
-
return `${start} ${ssrContext._meta.htmlAttrs || ''} ${end}`;
|
|
15
|
-
})
|
|
16
|
-
.replace(/(<head[^>]*)(>)/i, (_, start, end) => `${start}${end}${ssrContext._meta.headTags || ''}`)
|
|
17
|
-
.replace(/(<\/head>)/i, (_, tag) => `${ssrContext._meta.resourceStyles || ''}${ssrContext._meta.endingHeadTags || ''}${tag}`)
|
|
18
|
-
.replace(/(<body[^>]*)(>)/i, (found, start, end) => {
|
|
19
|
-
let classes = ssrContext._meta.bodyClasses || '';
|
|
20
|
-
const matches = found.match(/\sclass\s*=\s*['"]([^'"]*)['"]/i);
|
|
21
|
-
if (matches) {
|
|
22
|
-
if (matches[1].length > 0) {
|
|
23
|
-
classes += ` ${matches[1]}`;
|
|
24
|
-
}
|
|
25
|
-
start = start.replace(matches[0], '');
|
|
26
|
-
}
|
|
27
|
-
return `${start} class="${classes.trim()}" ${ssrContext._meta.bodyAttrs || ''}${end}${ssrContext._meta.bodyTags || ''}`;
|
|
28
|
-
});
|
|
29
|
-
export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
30
|
-
let plugins = [];
|
|
31
|
-
let quasarConf;
|
|
32
|
-
return [
|
|
33
|
-
{
|
|
34
|
-
name: 'vite-plugin-quasar-transform',
|
|
35
|
-
enforce: 'pre',
|
|
36
|
-
transform: (code, id, options) => {
|
|
37
|
-
code = code
|
|
38
|
-
.replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
|
|
39
|
-
.replaceAll('__QUASAR_SSR_SERVER__', ssr ? '(import.meta.env.SSR === true)' : 'false')
|
|
40
|
-
.replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '(import.meta.env.SSR === false)' : 'false')
|
|
41
|
-
.replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '(import.meta.env.SSR === false)' : 'false');
|
|
42
|
-
return code;
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'vite-plugin-quasar-setup',
|
|
47
|
-
enforce: 'pre',
|
|
48
|
-
config: async (config, env) => {
|
|
49
|
-
const { vitrify: { urls } = {}, quasar } = config;
|
|
50
|
-
const globalCss = quasar?.extras?.map((extra) => `@quasar/extras/${extra}/${extra}.css`);
|
|
51
|
-
const localPackages = ['@quasar/extras', 'quasar'];
|
|
52
|
-
// const localPackages: string[] = []
|
|
53
|
-
await (async () => {
|
|
54
|
-
for (const val of localPackages) {
|
|
55
|
-
const pkgDir = await findDepPkgJsonPath(val, fileURLToPath(config.vitrify.urls.app));
|
|
56
|
-
if (pkgDir)
|
|
57
|
-
urls.packages[val] = new URL(`file://${pkgDir}`);
|
|
58
|
-
}
|
|
59
|
-
})();
|
|
60
|
-
const onMountedHooks = [
|
|
61
|
-
async (instance) => {
|
|
62
|
-
const { proxy: { $q } } = instance;
|
|
63
|
-
if ($q.onSSRHydrated !== void 0)
|
|
64
|
-
$q.onSSRHydrated();
|
|
65
|
-
}
|
|
66
|
-
];
|
|
67
|
-
const onBootHooks = [
|
|
68
|
-
async ({ app, ssrContext, staticImports }) => {
|
|
69
|
-
// @ts-expect-error undefined
|
|
70
|
-
const quasarPlugins = await import('virtual:quasar-plugins');
|
|
71
|
-
// @ts-expect-error undefined
|
|
72
|
-
const directives = await import('virtual:quasar-directives');
|
|
73
|
-
// @ts-expect-error undefined
|
|
74
|
-
const { default: lang } = await import('virtual:quasar-lang');
|
|
75
|
-
// @ts-expect-error undefined
|
|
76
|
-
const { default: iconSet } = await import('virtual:quasar-iconSet');
|
|
77
|
-
const { default: iconMapFn } = await import(
|
|
78
|
-
// @ts-expect-error undefined
|
|
79
|
-
'virtual:quasar-iconMapFn');
|
|
80
|
-
app.use(staticImports?.Quasar, {
|
|
81
|
-
plugins: quasarPlugins,
|
|
82
|
-
directives,
|
|
83
|
-
lang,
|
|
84
|
-
iconSet,
|
|
85
|
-
config: {
|
|
86
|
-
iconMapFn
|
|
87
|
-
}
|
|
88
|
-
}, ssrContext);
|
|
89
|
-
}
|
|
90
|
-
];
|
|
91
|
-
if (quasar)
|
|
92
|
-
quasarConf = quasar;
|
|
93
|
-
if (!quasarConf.framework.lang && config.vitrify?.lang)
|
|
94
|
-
quasarConf.framework.lang = config.vitrify.lang;
|
|
95
|
-
/**
|
|
96
|
-
* Importing package.json is problematic
|
|
97
|
-
*/
|
|
98
|
-
const version = '?';
|
|
99
|
-
/**
|
|
100
|
-
* All components should have been auto-imported
|
|
101
|
-
*/
|
|
102
|
-
if (quasarConf?.framework?.plugins) {
|
|
103
|
-
if (!quasarConf.framework)
|
|
104
|
-
quasarConf.framework = {};
|
|
105
|
-
quasarConf.framework.plugins = [
|
|
106
|
-
...new Set(quasarConf.framework.plugins)
|
|
107
|
-
];
|
|
108
|
-
plugins = quasarConf?.framework.plugins;
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
vitrify: {
|
|
112
|
-
urls,
|
|
113
|
-
globalCss,
|
|
114
|
-
staticImports: {
|
|
115
|
-
quasar: ['Quasar']
|
|
116
|
-
},
|
|
117
|
-
hooks: {
|
|
118
|
-
onBoot: onBootHooks,
|
|
119
|
-
onMounted: onMountedHooks,
|
|
120
|
-
onRendered: [injectSsrContext]
|
|
121
|
-
},
|
|
122
|
-
sass: quasarConf.disableSass
|
|
123
|
-
? undefined
|
|
124
|
-
: {
|
|
125
|
-
global: ['quasar/src/css/index.sass']
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
resolve: {
|
|
129
|
-
alias: [
|
|
130
|
-
{
|
|
131
|
-
find: 'quasar/src/',
|
|
132
|
-
replacement: fileURLToPath(new URL('./src/', config.vitrify.urls.packages.quasar))
|
|
133
|
-
}
|
|
134
|
-
]
|
|
135
|
-
},
|
|
136
|
-
optimizeDeps: {
|
|
137
|
-
exclude: ['quasar']
|
|
138
|
-
},
|
|
139
|
-
define: {
|
|
140
|
-
__DEV__: process.env.NODE_ENV !== 'production' || true,
|
|
141
|
-
__QUASAR_VERSION__: `'${version}'`
|
|
142
|
-
},
|
|
143
|
-
ssr: {
|
|
144
|
-
noExternal: ['quasar']
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: 'quasar-virtual-modules',
|
|
151
|
-
enforce: 'pre',
|
|
152
|
-
config: async (config, env) => ({
|
|
153
|
-
resolve: {
|
|
154
|
-
alias: [
|
|
155
|
-
{
|
|
156
|
-
find: new RegExp('^quasar$'),
|
|
157
|
-
replacement: 'virtual:quasar'
|
|
158
|
-
}
|
|
159
|
-
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
160
|
-
]
|
|
161
|
-
}
|
|
162
|
-
}),
|
|
163
|
-
resolveId(id) {
|
|
164
|
-
switch (id) {
|
|
165
|
-
case 'virtual:quasar-plugins':
|
|
166
|
-
return 'virtual:quasar-plugins';
|
|
167
|
-
case 'virtual:quasar-directives':
|
|
168
|
-
return 'virtual:quasar-directives';
|
|
169
|
-
case 'virtual:quasar-lang':
|
|
170
|
-
return 'virtual:quasar-lang';
|
|
171
|
-
case 'virtual:quasar-iconSet':
|
|
172
|
-
return 'virtual:quasar-iconSet';
|
|
173
|
-
case 'virtual:quasar-iconMapFn':
|
|
174
|
-
return 'virtual:quasar-iconMapFn';
|
|
175
|
-
case 'virtual:quasar':
|
|
176
|
-
return { id: 'virtual:quasar', moduleSideEffects: false };
|
|
177
|
-
default:
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
load(id) {
|
|
182
|
-
if (id === 'virtual:quasar-plugins') {
|
|
183
|
-
return `export { ${plugins.join(',')} } from 'quasar'`;
|
|
184
|
-
}
|
|
185
|
-
else if (id === 'virtual:quasar-directives') {
|
|
186
|
-
return `export * from 'quasar/src/directives.js'`;
|
|
187
|
-
}
|
|
188
|
-
else if (id === 'virtual:quasar-lang') {
|
|
189
|
-
return `import lang from 'quasar/lang/${quasarConf?.framework?.lang || 'en-US'}';
|
|
190
|
-
export default lang`;
|
|
191
|
-
}
|
|
192
|
-
else if (id === 'virtual:quasar-iconSet') {
|
|
193
|
-
return `${typeof quasarConf.framework.iconSet === 'string'
|
|
194
|
-
? `import iconSet from 'quasar/icon-set/${quasarConf?.framework.iconSet || 'material-icons'}';
|
|
195
|
-
export default iconSet`
|
|
196
|
-
: `export default ${quasarConf.framework.iconSet
|
|
197
|
-
? JSON.stringify(quasarConf.framework.iconSet)
|
|
198
|
-
: null}`}`;
|
|
199
|
-
}
|
|
200
|
-
else if (id === 'virtual:quasar-iconMapFn') {
|
|
201
|
-
return `export default ${quasarConf?.framework.iconMapFn?.toString() ?? null}`;
|
|
202
|
-
}
|
|
203
|
-
else if (id === 'virtual:quasar') {
|
|
204
|
-
return `export * from 'quasar/src/plugins.js';
|
|
205
|
-
export * from 'quasar/src/components.js';
|
|
206
|
-
export * from 'quasar/src/composables.js';
|
|
207
|
-
export * from 'quasar/src/directives.js';
|
|
208
|
-
export * from 'quasar/src/utils.js';
|
|
209
|
-
export * from 'quasar/src/composables.js';
|
|
210
|
-
export { default as Quasar } from 'quasar/src/install-quasar.js'`;
|
|
211
|
-
}
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
];
|
|
216
|
-
};
|
|
217
|
-
export default QuasarPlugin;
|