vitrify 0.7.2 → 0.9.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/dist/bin/dev.js +8 -1
- package/dist/index.js +2 -0
- package/dist/plugins/quasar.js +14 -6
- package/dist/types/plugins/quasar.d.ts +1 -0
- package/package.json +3 -1
- package/src/node/bin/dev.ts +9 -1
- package/src/node/index.ts +2 -0
- package/src/node/plugins/quasar.ts +16 -6
- package/src/vite/vue/ssr/app.ts +1 -0
package/dist/bin/dev.js
CHANGED
|
@@ -2,6 +2,13 @@ import { searchForWorkspaceRoot } from 'vite';
|
|
|
2
2
|
import { baseConfig } from '../index.js';
|
|
3
3
|
import fastify from 'fastify';
|
|
4
4
|
import { fastifySsrPlugin } from '../frameworks/vue/fastify-ssr-plugin.js';
|
|
5
|
+
import isPortReachable from 'is-port-reachable';
|
|
6
|
+
const getFirstOpenPort = async (portNumber) => {
|
|
7
|
+
if (!(await isPortReachable(portNumber, { host: 'localhost' }))) {
|
|
8
|
+
return portNumber;
|
|
9
|
+
}
|
|
10
|
+
return getFirstOpenPort(portNumber + 1);
|
|
11
|
+
};
|
|
5
12
|
export async function createVitrifyDevServer({ port = 3000, logLevel = 'info',
|
|
6
13
|
// mode = 'csr',
|
|
7
14
|
ssr, framework = 'vue', host, appDir, publicDir, base }) {
|
|
@@ -29,7 +36,7 @@ ssr, framework = 'vue', host, appDir, publicDir, base }) {
|
|
|
29
36
|
https: config.server?.https,
|
|
30
37
|
hmr: {
|
|
31
38
|
protocol: config.server?.https ? 'wss' : 'ws',
|
|
32
|
-
port: 24678
|
|
39
|
+
port: await getFirstOpenPort(24678)
|
|
33
40
|
},
|
|
34
41
|
port,
|
|
35
42
|
// middlewareMode: mode === 'ssr' ? 'ssr' : undefined,
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import builtinModules from 'builtin-modules';
|
|
|
10
10
|
// import { resolve } from 'import-meta-resolve'
|
|
11
11
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
12
12
|
import { resolve } from './app-urls.js';
|
|
13
|
+
import envPlugin from '@vitrify/plugin-env';
|
|
13
14
|
const internalServerModules = [
|
|
14
15
|
'util',
|
|
15
16
|
'vitrify',
|
|
@@ -196,6 +197,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
196
197
|
];
|
|
197
198
|
const plugins = [
|
|
198
199
|
vuePlugin(),
|
|
200
|
+
envPlugin(),
|
|
199
201
|
...frameworkPlugins,
|
|
200
202
|
{
|
|
201
203
|
name: 'vitrify-setup',
|
package/dist/plugins/quasar.js
CHANGED
|
@@ -38,12 +38,11 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
38
38
|
name: 'vite-plugin-quasar-transform',
|
|
39
39
|
enforce: 'pre',
|
|
40
40
|
transform: (code, id, options) => {
|
|
41
|
-
const { ssr: transformSsr } = options || {};
|
|
42
41
|
code = code
|
|
43
42
|
.replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
|
|
44
|
-
.replaceAll('__QUASAR_SSR_SERVER__', ssr
|
|
45
|
-
.replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '
|
|
46
|
-
.replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '
|
|
43
|
+
.replaceAll('__QUASAR_SSR_SERVER__', ssr ? '(import.meta.env.SSR === true)' : 'false')
|
|
44
|
+
.replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '(import.meta.env.SSR === false)' : 'false')
|
|
45
|
+
.replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '(import.meta.env.SSR === false)' : 'false');
|
|
47
46
|
return code;
|
|
48
47
|
}
|
|
49
48
|
},
|
|
@@ -52,7 +51,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
52
51
|
enforce: 'pre',
|
|
53
52
|
config: async (config, env) => {
|
|
54
53
|
const { vitrify: { urls } = {}, quasar } = config;
|
|
55
|
-
const globalCss = quasar?.extras
|
|
54
|
+
const globalCss = quasar?.extras?.map((extra) => `@quasar/extras/${extra}/${extra}.css`);
|
|
56
55
|
const localPackages = ['@quasar/extras', 'quasar'];
|
|
57
56
|
// const localPackages: string[] = []
|
|
58
57
|
await (async () => {
|
|
@@ -77,10 +76,13 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
77
76
|
const directives = await import('virtual:quasar-directives');
|
|
78
77
|
// @ts-ignore
|
|
79
78
|
const { default: lang } = await import('virtual:quasar-lang');
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
const { default: iconSet } = await import('virtual:quasar-iconSet');
|
|
80
81
|
app.use(staticImports?.Quasar, {
|
|
81
82
|
plugins: quasarPlugins,
|
|
82
83
|
directives,
|
|
83
|
-
lang
|
|
84
|
+
lang,
|
|
85
|
+
iconSet
|
|
84
86
|
}, ssrContext);
|
|
85
87
|
}
|
|
86
88
|
];
|
|
@@ -163,6 +165,8 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
163
165
|
return 'virtual:quasar-directives';
|
|
164
166
|
case 'virtual:quasar-lang':
|
|
165
167
|
return 'virtual:quasar-lang';
|
|
168
|
+
case 'virtual:quasar-iconSet':
|
|
169
|
+
return 'virtual:quasar-iconSet';
|
|
166
170
|
case 'virtual:quasar':
|
|
167
171
|
return { id: 'virtual:quasar', moduleSideEffects: false };
|
|
168
172
|
default:
|
|
@@ -179,6 +183,10 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
179
183
|
else if (id === 'virtual:quasar-lang') {
|
|
180
184
|
return `import lang from 'quasar/lang/${quasarConf?.framework?.lang || 'en-US'}';
|
|
181
185
|
export default lang`;
|
|
186
|
+
}
|
|
187
|
+
else if (id === 'virtual:quasar-iconSet') {
|
|
188
|
+
return `import iconSet from 'quasar/icon-set/${quasarConf?.framework.iconSet || 'material-icons'}';
|
|
189
|
+
export default iconSet`;
|
|
182
190
|
}
|
|
183
191
|
else if (id === 'virtual:quasar') {
|
|
184
192
|
return `export * from 'quasar/src/plugins.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitrify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Stefan van Herwijnen",
|
|
6
6
|
"description": "Pre-configured Vite CLI for your framework",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"@fastify/static": "^6.5.0",
|
|
61
61
|
"@quasar/extras": "^1.15.1",
|
|
62
62
|
"@vitejs/plugin-vue": "^3.0.1",
|
|
63
|
+
"@vitrify/plugin-env": "^0.1.0",
|
|
63
64
|
"builtin-modules": "^3.3.0",
|
|
64
65
|
"cac": "^6.7.12",
|
|
65
66
|
"chalk": "^5.0.1",
|
|
@@ -69,6 +70,7 @@
|
|
|
69
70
|
"fastify": "^4.3.0",
|
|
70
71
|
"glob": "^8.0.3",
|
|
71
72
|
"happy-dom": "^6.0.4",
|
|
73
|
+
"is-port-reachable": "^4.0.0",
|
|
72
74
|
"magic-string": "^0.26.2",
|
|
73
75
|
"merge-deep": "^3.0.3",
|
|
74
76
|
"readline": "^1.3.0",
|
package/src/node/bin/dev.ts
CHANGED
|
@@ -6,6 +6,14 @@ import fastify from 'fastify'
|
|
|
6
6
|
import type { FastifyServerOptions } from 'fastify'
|
|
7
7
|
import { fastifySsrPlugin } from '../frameworks/vue/fastify-ssr-plugin.js'
|
|
8
8
|
import type { OnRenderedHook, VitrifyConfig } from '../vitrify-config.js'
|
|
9
|
+
import isPortReachable from 'is-port-reachable'
|
|
10
|
+
|
|
11
|
+
const getFirstOpenPort = async (portNumber: number): Promise<number> => {
|
|
12
|
+
if (!(await isPortReachable(portNumber, { host: 'localhost' }))) {
|
|
13
|
+
return portNumber
|
|
14
|
+
}
|
|
15
|
+
return getFirstOpenPort(portNumber + 1)
|
|
16
|
+
}
|
|
9
17
|
|
|
10
18
|
export async function createVitrifyDevServer({
|
|
11
19
|
port = 3000,
|
|
@@ -55,7 +63,7 @@ export async function createVitrifyDevServer({
|
|
|
55
63
|
https: config.server?.https,
|
|
56
64
|
hmr: {
|
|
57
65
|
protocol: config.server?.https ? 'wss' : 'ws',
|
|
58
|
-
port: 24678
|
|
66
|
+
port: await getFirstOpenPort(24678)
|
|
59
67
|
},
|
|
60
68
|
port,
|
|
61
69
|
// middlewareMode: mode === 'ssr' ? 'ssr' : undefined,
|
package/src/node/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type { VitrifyContext } from './bin/run.js'
|
|
|
23
23
|
import type { VitrifyPlugin } from './plugins/index.js'
|
|
24
24
|
import { resolve } from './app-urls.js'
|
|
25
25
|
import type { ManualChunksOption, RollupOptions } from 'rollup'
|
|
26
|
+
import envPlugin from '@vitrify/plugin-env'
|
|
26
27
|
|
|
27
28
|
const internalServerModules = [
|
|
28
29
|
'util',
|
|
@@ -269,6 +270,7 @@ export const baseConfig = async ({
|
|
|
269
270
|
|
|
270
271
|
const plugins: UserConfig['plugins'] = [
|
|
271
272
|
vuePlugin(),
|
|
273
|
+
envPlugin(),
|
|
272
274
|
...frameworkPlugins,
|
|
273
275
|
{
|
|
274
276
|
name: 'vitrify-setup',
|
|
@@ -17,6 +17,7 @@ export interface QuasarConf {
|
|
|
17
17
|
directives?: string[]
|
|
18
18
|
plugins?: string[]
|
|
19
19
|
lang?: string
|
|
20
|
+
iconSet?: string
|
|
20
21
|
}
|
|
21
22
|
animations: string[]
|
|
22
23
|
extras: string[]
|
|
@@ -84,20 +85,19 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
84
85
|
name: 'vite-plugin-quasar-transform',
|
|
85
86
|
enforce: 'pre',
|
|
86
87
|
transform: (code, id, options) => {
|
|
87
|
-
const { ssr: transformSsr } = options || {}
|
|
88
88
|
code = code
|
|
89
89
|
.replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
|
|
90
90
|
.replaceAll(
|
|
91
91
|
'__QUASAR_SSR_SERVER__',
|
|
92
|
-
ssr
|
|
92
|
+
ssr ? '(import.meta.env.SSR === true)' : 'false'
|
|
93
93
|
)
|
|
94
94
|
.replaceAll(
|
|
95
95
|
'__QUASAR_SSR_CLIENT__',
|
|
96
|
-
ssr ? '
|
|
96
|
+
ssr ? '(import.meta.env.SSR === false)' : 'false'
|
|
97
97
|
)
|
|
98
98
|
.replaceAll(
|
|
99
99
|
'__QUASAR_SSR_PWA__',
|
|
100
|
-
ssr && pwa ? '
|
|
100
|
+
ssr && pwa ? '(import.meta.env.SSR === false)' : 'false'
|
|
101
101
|
)
|
|
102
102
|
|
|
103
103
|
return code
|
|
@@ -109,7 +109,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
109
109
|
config: async (config: VitrifyConfig, env): Promise<VitrifyConfig> => {
|
|
110
110
|
const { vitrify: { urls } = {}, quasar } = config
|
|
111
111
|
|
|
112
|
-
const globalCss = quasar?.extras
|
|
112
|
+
const globalCss = quasar?.extras?.map(
|
|
113
113
|
(extra) => `@quasar/extras/${extra}/${extra}.css`
|
|
114
114
|
)
|
|
115
115
|
|
|
@@ -143,13 +143,16 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
143
143
|
const directives = await import('virtual:quasar-directives')
|
|
144
144
|
// @ts-ignore
|
|
145
145
|
const { default: lang } = await import('virtual:quasar-lang')
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
const { default: iconSet } = await import('virtual:quasar-iconSet')
|
|
146
148
|
|
|
147
149
|
app.use(
|
|
148
150
|
staticImports?.Quasar,
|
|
149
151
|
{
|
|
150
152
|
plugins: quasarPlugins,
|
|
151
153
|
directives,
|
|
152
|
-
lang
|
|
154
|
+
lang,
|
|
155
|
+
iconSet
|
|
153
156
|
},
|
|
154
157
|
ssrContext
|
|
155
158
|
)
|
|
@@ -239,6 +242,8 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
239
242
|
return 'virtual:quasar-directives'
|
|
240
243
|
case 'virtual:quasar-lang':
|
|
241
244
|
return 'virtual:quasar-lang'
|
|
245
|
+
case 'virtual:quasar-iconSet':
|
|
246
|
+
return 'virtual:quasar-iconSet'
|
|
242
247
|
case 'virtual:quasar':
|
|
243
248
|
return { id: 'virtual:quasar', moduleSideEffects: false }
|
|
244
249
|
default:
|
|
@@ -255,6 +260,11 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
255
260
|
quasarConf?.framework?.lang || 'en-US'
|
|
256
261
|
}';
|
|
257
262
|
export default lang`
|
|
263
|
+
} else if (id === 'virtual:quasar-iconSet') {
|
|
264
|
+
return `import iconSet from 'quasar/icon-set/${
|
|
265
|
+
quasarConf?.framework.iconSet || 'material-icons'
|
|
266
|
+
}';
|
|
267
|
+
export default iconSet`
|
|
258
268
|
} else if (id === 'virtual:quasar') {
|
|
259
269
|
return `export * from 'quasar/src/plugins.js';
|
|
260
270
|
export * from 'quasar/src/components.js';
|