vitrify 0.5.0 → 0.5.3
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/build.js +3 -2
- package/dist/bin/cli.js +3 -1
- package/dist/bin/dev.js +2 -2
- package/dist/index.js +41 -40
- package/dist/plugins/quasar.js +13 -15
- package/dist/types/bin/build.d.ts +1 -0
- package/dist/types/bin/dev.d.ts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/vitrify-config.d.ts +1 -0
- package/package.json +5 -5
- package/src/node/bin/build.ts +4 -2
- package/src/node/bin/cli.ts +4 -1
- package/src/node/bin/dev.ts +2 -2
- package/src/node/index.ts +46 -45
- package/src/node/plugins/quasar.ts +20 -16
- package/src/node/vitrify-config.ts +1 -1
- package/src/vite/vue/main.ts +2 -0
package/dist/bin/build.js
CHANGED
|
@@ -8,11 +8,12 @@ export async function build(opts) {
|
|
|
8
8
|
ssr: opts?.ssr,
|
|
9
9
|
appDir: opts.appDir,
|
|
10
10
|
publicDir: opts.publicDir,
|
|
11
|
-
base: opts.base
|
|
11
|
+
base: opts.base,
|
|
12
|
+
debug: opts.debug
|
|
12
13
|
});
|
|
13
14
|
config.build = {
|
|
14
15
|
...config.build,
|
|
15
|
-
minify:
|
|
16
|
+
minify: !opts.debug,
|
|
16
17
|
outDir: opts.outDir,
|
|
17
18
|
emptyOutDir: !!opts.outDir
|
|
18
19
|
};
|
package/dist/bin/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ cli
|
|
|
11
11
|
.option('--appDir [appDir]', 'App directory')
|
|
12
12
|
.option('--publicDir [publicDir]', 'Public directory')
|
|
13
13
|
.option('--productName [productName]', 'Product name')
|
|
14
|
+
.option('--debug', 'Debug build')
|
|
14
15
|
.action(async (options) => {
|
|
15
16
|
const { build } = await import('./build.js');
|
|
16
17
|
let appDir;
|
|
@@ -27,7 +28,8 @@ cli
|
|
|
27
28
|
const args = {
|
|
28
29
|
base: options.base,
|
|
29
30
|
appDir,
|
|
30
|
-
publicDir: parsePath(options.publicDir, appDir)
|
|
31
|
+
publicDir: parsePath(options.publicDir, appDir),
|
|
32
|
+
debug: options.debug
|
|
31
33
|
};
|
|
32
34
|
switch (options.mode) {
|
|
33
35
|
case 'csr':
|
package/dist/bin/dev.js
CHANGED
|
@@ -25,11 +25,11 @@ ssr, framework = 'vue', host, appDir, publicDir, base }) {
|
|
|
25
25
|
base
|
|
26
26
|
});
|
|
27
27
|
config.logLevel = logLevel;
|
|
28
|
-
console.log(searchForWorkspaceRoot(appDir.pathname));
|
|
29
28
|
config.server = {
|
|
30
29
|
https: config.server?.https,
|
|
31
30
|
hmr: {
|
|
32
|
-
protocol: config.server?.https ? 'wss' : 'ws'
|
|
31
|
+
protocol: config.server?.https ? 'wss' : 'ws',
|
|
32
|
+
port: 24678
|
|
33
33
|
},
|
|
34
34
|
port,
|
|
35
35
|
// middlewareMode: mode === 'ssr' ? 'ssr' : undefined,
|
package/dist/index.js
CHANGED
|
@@ -7,38 +7,16 @@ import { pathToFileURL } from 'url';
|
|
|
7
7
|
import { readFileSync } from 'fs';
|
|
8
8
|
import builtinModules from 'builtin-modules';
|
|
9
9
|
import { resolve } from 'import-meta-resolve';
|
|
10
|
+
import { visualizer } from 'rollup-plugin-visualizer';
|
|
10
11
|
import { getPkgJsonDir } from './app-urls.js';
|
|
11
12
|
const internalServerModules = [
|
|
12
|
-
// 'fs',
|
|
13
|
-
// 'path',
|
|
14
|
-
// 'url',
|
|
15
|
-
// 'module',
|
|
16
|
-
// 'crypto',
|
|
17
|
-
// 'node:fs',
|
|
18
13
|
'util',
|
|
19
|
-
'node:url',
|
|
20
|
-
'node:util',
|
|
21
|
-
'node:fs',
|
|
22
|
-
'node:process',
|
|
23
14
|
'vitrify',
|
|
24
15
|
'vitrify/dev',
|
|
25
|
-
// 'import-meta-resolve',
|
|
26
16
|
'vite',
|
|
27
17
|
'fastify',
|
|
28
|
-
'@fastify',
|
|
18
|
+
'@fastify/static',
|
|
29
19
|
'node'
|
|
30
|
-
// 'middie',
|
|
31
|
-
// 'knex',
|
|
32
|
-
// 'bcrypt',
|
|
33
|
-
// 'objection',
|
|
34
|
-
// '@fastify/formbody',
|
|
35
|
-
// '@fastify/static',
|
|
36
|
-
// '@fastify/cors',
|
|
37
|
-
// '@fastify/cookie',
|
|
38
|
-
// 'mercurius',
|
|
39
|
-
// 'jose',
|
|
40
|
-
// 'oidc-provider',
|
|
41
|
-
// 'node-fetch'
|
|
42
20
|
];
|
|
43
21
|
const configPluginMap = {
|
|
44
22
|
quasar: () => import('./plugins/quasar.js').then((module) => module.QuasarPlugin)
|
|
@@ -55,6 +33,9 @@ const manualChunks = (id) => {
|
|
|
55
33
|
if (name && manualChunkNames.includes(name))
|
|
56
34
|
return name;
|
|
57
35
|
}
|
|
36
|
+
else if (VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))) {
|
|
37
|
+
return VIRTUAL_MODULES.find((name) => id.includes(name));
|
|
38
|
+
}
|
|
58
39
|
else if (id.includes('node_modules')) {
|
|
59
40
|
return 'vendor';
|
|
60
41
|
}
|
|
@@ -62,7 +43,9 @@ const manualChunks = (id) => {
|
|
|
62
43
|
export const VIRTUAL_MODULES = [
|
|
63
44
|
'virtual:vitrify-hooks',
|
|
64
45
|
'virtual:global-css',
|
|
65
|
-
'virtual:static-imports'
|
|
46
|
+
'virtual:static-imports',
|
|
47
|
+
'vitrify.sass',
|
|
48
|
+
'vitrify.css'
|
|
66
49
|
];
|
|
67
50
|
async function bundleConfigFile(fileName, isESM = false) {
|
|
68
51
|
const result = await build({
|
|
@@ -112,7 +95,7 @@ async function bundleConfigFile(fileName, isESM = false) {
|
|
|
112
95
|
dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
|
|
113
96
|
};
|
|
114
97
|
}
|
|
115
|
-
export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command = 'build', mode = 'production', framework = 'vue', pwa = false }) => {
|
|
98
|
+
export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command = 'build', mode = 'production', framework = 'vue', pwa = false, debug = false }) => {
|
|
116
99
|
const { getAppDir, getCliDir, getCliViteDir, getSrcDir, getCwd } = await import('./app-urls.js');
|
|
117
100
|
if (!appDir) {
|
|
118
101
|
appDir = getAppDir();
|
|
@@ -194,6 +177,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
194
177
|
let staticImports;
|
|
195
178
|
let sassVariables;
|
|
196
179
|
let additionalData;
|
|
180
|
+
let globalSass;
|
|
197
181
|
let serverModules = internalServerModules;
|
|
198
182
|
if (vitrifyConfig.vitrify?.ssr?.serverModules)
|
|
199
183
|
serverModules = [
|
|
@@ -234,17 +218,20 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
234
218
|
globalCss = config.vitrify?.globalCss || [];
|
|
235
219
|
staticImports = config.vitrify?.staticImports || {};
|
|
236
220
|
sassVariables = config.vitrify?.sass?.variables || {};
|
|
221
|
+
globalSass = config.vitrify?.sass?.global || [];
|
|
237
222
|
additionalData = config.vitrify?.sass?.additionalData || [];
|
|
238
223
|
return {
|
|
239
224
|
css: {
|
|
240
225
|
preprocessorOptions: {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
226
|
+
// sass: {
|
|
227
|
+
// additionalData: [
|
|
228
|
+
// ...Object.entries(sassVariables).map(
|
|
229
|
+
// ([key, value]) => `${key}: ${value}`
|
|
230
|
+
// )
|
|
231
|
+
// // ...additionalData
|
|
232
|
+
// // config.css?.preprocessorOptions?.sass.additionalData
|
|
233
|
+
// ].join('\n')
|
|
234
|
+
// }
|
|
248
235
|
}
|
|
249
236
|
}
|
|
250
237
|
};
|
|
@@ -257,7 +244,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
257
244
|
},
|
|
258
245
|
resolveId(id) {
|
|
259
246
|
if (VIRTUAL_MODULES.includes(id))
|
|
260
|
-
return { id
|
|
247
|
+
return { id };
|
|
261
248
|
return;
|
|
262
249
|
},
|
|
263
250
|
transform: (code, id) => {
|
|
@@ -300,6 +287,15 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
300
287
|
.map(([key, value]) => `export { ${value.join(',')} } from '${key}';`)
|
|
301
288
|
.join('\n')}`;
|
|
302
289
|
}
|
|
290
|
+
else if (id === 'vitrify.sass') {
|
|
291
|
+
return [
|
|
292
|
+
...Object.entries(sassVariables).map(([key, value]) => `${key}: ${value}`),
|
|
293
|
+
...globalSass.map((sass) => `@import '${sass}'`)
|
|
294
|
+
].join('\n');
|
|
295
|
+
}
|
|
296
|
+
else if (id === 'vitrify.css') {
|
|
297
|
+
return `${globalCss.map((css) => `import '${css}'`).join('\n')}`;
|
|
298
|
+
}
|
|
303
299
|
return null;
|
|
304
300
|
}
|
|
305
301
|
}
|
|
@@ -357,6 +353,8 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
357
353
|
}
|
|
358
354
|
}
|
|
359
355
|
});
|
|
356
|
+
if (debug)
|
|
357
|
+
plugins.push(visualizer());
|
|
360
358
|
}
|
|
361
359
|
const alias = [
|
|
362
360
|
{ find: 'src', replacement: srcDir.pathname },
|
|
@@ -386,6 +384,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
386
384
|
const external = [...builtinModules, ...serverModules];
|
|
387
385
|
if (ssr === 'server') {
|
|
388
386
|
rollupOptions = {
|
|
387
|
+
...rollupOptions,
|
|
389
388
|
input: [
|
|
390
389
|
new URL('ssr/entry-server.ts', frameworkDir).pathname,
|
|
391
390
|
new URL('ssr/prerender.ts', frameworkDir).pathname,
|
|
@@ -393,7 +392,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
393
392
|
],
|
|
394
393
|
external,
|
|
395
394
|
output: {
|
|
396
|
-
minifyInternalExports:
|
|
395
|
+
minifyInternalExports: !debug,
|
|
397
396
|
entryFileNames: '[name].mjs',
|
|
398
397
|
chunkFileNames: '[name].mjs',
|
|
399
398
|
format: 'es',
|
|
@@ -416,6 +415,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
416
415
|
}
|
|
417
416
|
else if (ssr === 'fastify') {
|
|
418
417
|
rollupOptions = {
|
|
418
|
+
...rollupOptions,
|
|
419
419
|
input: [new URL('server.ts', fastifyDir).pathname],
|
|
420
420
|
external,
|
|
421
421
|
output: {
|
|
@@ -441,13 +441,14 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
441
441
|
}
|
|
442
442
|
else {
|
|
443
443
|
rollupOptions = {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
444
|
+
...rollupOptions,
|
|
445
|
+
// input: [
|
|
446
|
+
// new URL('index.html', frameworkDir).pathname
|
|
447
|
+
// // new URL('csr/server.ts', frameworkDir).pathname
|
|
448
|
+
// ],
|
|
448
449
|
external,
|
|
449
450
|
output: {
|
|
450
|
-
minifyInternalExports:
|
|
451
|
+
minifyInternalExports: !debug,
|
|
451
452
|
entryFileNames: '[name].mjs',
|
|
452
453
|
chunkFileNames: '[name].mjs',
|
|
453
454
|
format: 'es',
|
package/dist/plugins/quasar.js
CHANGED
|
@@ -44,9 +44,9 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
44
44
|
const { ssr } = options || {};
|
|
45
45
|
code = code
|
|
46
46
|
.replaceAll('__QUASAR_SSR__', ssr ? ssr.toString() : 'false')
|
|
47
|
-
.replaceAll('__QUASAR_SSR_SERVER__', 'import.meta.env.SSR')
|
|
48
|
-
.replaceAll('__QUASAR_SSR_CLIENT__', '!import.meta.env.SSR')
|
|
49
|
-
.replaceAll('__QUASAR_SSR_PWA__', pwa ? '!import.meta.env.SSR' : 'false');
|
|
47
|
+
.replaceAll('__QUASAR_SSR_SERVER__', ssr ? 'import.meta.env.SSR' : 'false')
|
|
48
|
+
.replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '!import.meta.env.SSR' : 'false')
|
|
49
|
+
.replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '!import.meta.env.SSR' : 'false');
|
|
50
50
|
return code;
|
|
51
51
|
}
|
|
52
52
|
},
|
|
@@ -93,7 +93,8 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
93
93
|
onRendered: [injectSsrContext]
|
|
94
94
|
},
|
|
95
95
|
sass: {
|
|
96
|
-
|
|
96
|
+
global: ['quasar/src/css/index.sass']
|
|
97
|
+
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
};
|
|
@@ -149,20 +150,17 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
149
150
|
find: 'quasar/src',
|
|
150
151
|
replacement: new URL('src/', urls?.packages?.quasar).pathname
|
|
151
152
|
},
|
|
152
|
-
{
|
|
153
|
-
find: new RegExp('^quasar$'),
|
|
154
|
-
replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
155
|
-
.pathname
|
|
156
|
-
},
|
|
157
153
|
// {
|
|
158
|
-
// find: 'quasar',
|
|
159
|
-
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
154
|
+
// find: new RegExp('^quasar$'),
|
|
155
|
+
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
156
|
+
// .pathname
|
|
160
157
|
// },
|
|
161
158
|
{
|
|
162
159
|
find: `@quasar/extras`,
|
|
163
160
|
replacement: new URL('.', urls?.packages?.['@quasar/extras'])
|
|
164
161
|
.pathname
|
|
165
162
|
}
|
|
163
|
+
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
166
164
|
]
|
|
167
165
|
},
|
|
168
166
|
define: {
|
|
@@ -184,7 +182,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
184
182
|
},
|
|
185
183
|
{
|
|
186
184
|
name: 'quasar-virtual-modules',
|
|
187
|
-
enforce: '
|
|
185
|
+
enforce: 'pre',
|
|
188
186
|
config: async (config, env) => ({
|
|
189
187
|
resolve: {
|
|
190
188
|
alias: [
|
|
@@ -196,8 +194,8 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
196
194
|
switch (id) {
|
|
197
195
|
case 'virtual:quasar-plugins':
|
|
198
196
|
return 'virtual:quasar-plugins';
|
|
199
|
-
case '
|
|
200
|
-
return { id: '
|
|
197
|
+
case 'quasar':
|
|
198
|
+
return { id: 'quasar', moduleSideEffects: false };
|
|
201
199
|
default:
|
|
202
200
|
return;
|
|
203
201
|
}
|
|
@@ -206,7 +204,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
206
204
|
if (id === 'virtual:quasar-plugins') {
|
|
207
205
|
return `export { ${plugins.join(',')} } from 'quasar'`;
|
|
208
206
|
}
|
|
209
|
-
else if (id === '
|
|
207
|
+
else if (id === 'quasar') {
|
|
210
208
|
return `export * from 'quasar/src/plugins.js';
|
|
211
209
|
export * from 'quasar/src/components.js';
|
|
212
210
|
export * from 'quasar/src/composables.js';
|
package/dist/types/bin/dev.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
|
|
|
48
48
|
createResolver: (options?: Partial<import("vite").InternalResolveOptions> | undefined) => import("vite").ResolveFn;
|
|
49
49
|
optimizeDeps: import("vite").DepOptimizationOptions;
|
|
50
50
|
worker: import("vite").ResolveWorkerOptions;
|
|
51
|
-
|
|
51
|
+
appType: import("vite").AppType;
|
|
52
|
+
experimental: import("vite").ResolvedExperimentalOptions;
|
|
52
53
|
}>;
|
|
53
54
|
}>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { BootFunction, VitrifyConfig } from './vitrify-config.js';
|
|
|
3
3
|
import type { VitrifyContext } from './bin/run.js';
|
|
4
4
|
import type { VitrifyPlugin } from './plugins/index.js';
|
|
5
5
|
export declare const VIRTUAL_MODULES: string[];
|
|
6
|
-
export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode, framework, pwa }: {
|
|
6
|
+
export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode, framework, pwa, debug }: {
|
|
7
7
|
ssr?: "server" | "client" | "ssg" | "fastify" | undefined;
|
|
8
8
|
appDir?: URL | undefined;
|
|
9
9
|
publicDir?: URL | undefined;
|
|
@@ -12,6 +12,7 @@ export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode,
|
|
|
12
12
|
mode?: "production" | "development" | undefined;
|
|
13
13
|
framework?: "vue" | undefined;
|
|
14
14
|
pwa?: boolean | undefined;
|
|
15
|
+
debug?: boolean | undefined;
|
|
15
16
|
}) => Promise<InlineConfig>;
|
|
16
17
|
export declare const vitrifyDir: URL;
|
|
17
18
|
export type { VitrifyConfig, VitrifyPlugin, VitrifyContext, BootFunction };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitrify",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Stefan van Herwijnen",
|
|
6
6
|
"description": "Pre-configured Vite CLI for your framework",
|
|
@@ -68,10 +68,11 @@
|
|
|
68
68
|
"magic-string": "^0.26.2",
|
|
69
69
|
"merge-deep": "^3.0.3",
|
|
70
70
|
"readline": "^1.3.0",
|
|
71
|
+
"rollup-plugin-visualizer": "^5.6.0",
|
|
71
72
|
"sass": "1.52.3",
|
|
72
73
|
"ts-node": "^10.8.1",
|
|
73
74
|
"unplugin-vue-components": "^0.19.6",
|
|
74
|
-
"vite": "^3.0.0-
|
|
75
|
+
"vite": "^3.0.0-beta.0",
|
|
75
76
|
"vitest": "^0.14.1"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
@@ -92,11 +93,10 @@
|
|
|
92
93
|
"peerDependencies": {
|
|
93
94
|
"@fastify/static": "^6.4.0",
|
|
94
95
|
"fastify": "^4.0.0",
|
|
95
|
-
"
|
|
96
|
+
"import-meta-resolve": "^2.0.3",
|
|
96
97
|
"quasar": "^2.7.1",
|
|
97
98
|
"vue": "^3.2.37",
|
|
98
|
-
"vue-router": "^4.0.15"
|
|
99
|
-
"import-meta-resolve": "^2.0.3"
|
|
99
|
+
"vue-router": "^4.0.15"
|
|
100
100
|
},
|
|
101
101
|
"publishConfig": {
|
|
102
102
|
"access": "public",
|
package/src/node/bin/build.ts
CHANGED
|
@@ -8,6 +8,7 @@ export async function build(opts: {
|
|
|
8
8
|
outDir: string
|
|
9
9
|
appDir?: URL
|
|
10
10
|
publicDir?: URL
|
|
11
|
+
debug?: boolean
|
|
11
12
|
}) {
|
|
12
13
|
const config = await baseConfig({
|
|
13
14
|
command: 'build',
|
|
@@ -15,12 +16,13 @@ export async function build(opts: {
|
|
|
15
16
|
ssr: opts?.ssr,
|
|
16
17
|
appDir: opts.appDir,
|
|
17
18
|
publicDir: opts.publicDir,
|
|
18
|
-
base: opts.base
|
|
19
|
+
base: opts.base,
|
|
20
|
+
debug: opts.debug
|
|
19
21
|
})
|
|
20
22
|
|
|
21
23
|
config.build = {
|
|
22
24
|
...config.build,
|
|
23
|
-
minify:
|
|
25
|
+
minify: !opts.debug,
|
|
24
26
|
outDir: opts.outDir,
|
|
25
27
|
emptyOutDir: !!opts.outDir
|
|
26
28
|
}
|
package/src/node/bin/cli.ts
CHANGED
|
@@ -20,6 +20,7 @@ cli
|
|
|
20
20
|
.option('--appDir [appDir]', 'App directory')
|
|
21
21
|
.option('--publicDir [publicDir]', 'Public directory')
|
|
22
22
|
.option('--productName [productName]', 'Product name')
|
|
23
|
+
.option('--debug', 'Debug build')
|
|
23
24
|
.action(async (options) => {
|
|
24
25
|
const { build } = await import('./build.js')
|
|
25
26
|
let appDir: URL
|
|
@@ -38,10 +39,12 @@ cli
|
|
|
38
39
|
base: string
|
|
39
40
|
appDir?: URL
|
|
40
41
|
publicDir?: URL
|
|
42
|
+
debug?: boolean
|
|
41
43
|
} = {
|
|
42
44
|
base: options.base,
|
|
43
45
|
appDir,
|
|
44
|
-
publicDir: parsePath(options.publicDir, appDir)
|
|
46
|
+
publicDir: parsePath(options.publicDir, appDir),
|
|
47
|
+
debug: options.debug
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
switch (options.mode) {
|
package/src/node/bin/dev.ts
CHANGED
|
@@ -52,11 +52,11 @@ export async function createVitrifyDevServer({
|
|
|
52
52
|
|
|
53
53
|
config.logLevel = logLevel
|
|
54
54
|
|
|
55
|
-
console.log(searchForWorkspaceRoot(appDir.pathname))
|
|
56
55
|
config.server = {
|
|
57
56
|
https: config.server?.https,
|
|
58
57
|
hmr: {
|
|
59
|
-
protocol: config.server?.https ? 'wss' : 'ws'
|
|
58
|
+
protocol: config.server?.https ? 'wss' : 'ws',
|
|
59
|
+
port: 24678
|
|
60
60
|
},
|
|
61
61
|
port,
|
|
62
62
|
// middlewareMode: mode === 'ssr' ? 'ssr' : undefined,
|
package/src/node/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { pathToFileURL } from 'url'
|
|
|
9
9
|
import { readFileSync } from 'fs'
|
|
10
10
|
import builtinModules from 'builtin-modules'
|
|
11
11
|
import { resolve } from 'import-meta-resolve'
|
|
12
|
+
import { visualizer } from 'rollup-plugin-visualizer'
|
|
12
13
|
import type {
|
|
13
14
|
StaticImports,
|
|
14
15
|
BootFunction,
|
|
@@ -21,39 +22,16 @@ import type {
|
|
|
21
22
|
import type { VitrifyContext } from './bin/run.js'
|
|
22
23
|
import type { VitrifyPlugin } from './plugins/index.js'
|
|
23
24
|
import { getPkgJsonDir } from './app-urls.js'
|
|
24
|
-
import type { RollupOptions } from 'rollup'
|
|
25
|
+
import type { ManualChunksOption, RollupOptions } from 'rollup'
|
|
25
26
|
|
|
26
27
|
const internalServerModules = [
|
|
27
|
-
// 'fs',
|
|
28
|
-
// 'path',
|
|
29
|
-
// 'url',
|
|
30
|
-
// 'module',
|
|
31
|
-
// 'crypto',
|
|
32
|
-
// 'node:fs',
|
|
33
28
|
'util',
|
|
34
|
-
'node:url',
|
|
35
|
-
'node:util',
|
|
36
|
-
'node:fs',
|
|
37
|
-
'node:process',
|
|
38
29
|
'vitrify',
|
|
39
30
|
'vitrify/dev',
|
|
40
|
-
// 'import-meta-resolve',
|
|
41
31
|
'vite',
|
|
42
32
|
'fastify',
|
|
43
|
-
'@fastify',
|
|
33
|
+
'@fastify/static',
|
|
44
34
|
'node'
|
|
45
|
-
// 'middie',
|
|
46
|
-
// 'knex',
|
|
47
|
-
// 'bcrypt',
|
|
48
|
-
// 'objection',
|
|
49
|
-
// '@fastify/formbody',
|
|
50
|
-
// '@fastify/static',
|
|
51
|
-
// '@fastify/cors',
|
|
52
|
-
// '@fastify/cookie',
|
|
53
|
-
// 'mercurius',
|
|
54
|
-
// 'jose',
|
|
55
|
-
// 'oidc-provider',
|
|
56
|
-
// 'node-fetch'
|
|
57
35
|
]
|
|
58
36
|
|
|
59
37
|
const configPluginMap: Record<string, () => Promise<VitrifyPlugin>> = {
|
|
@@ -67,10 +45,14 @@ const manualChunkNames = [
|
|
|
67
45
|
'fastify-csr-plugin',
|
|
68
46
|
'server'
|
|
69
47
|
]
|
|
70
|
-
const manualChunks = (id: string) => {
|
|
48
|
+
const manualChunks: ManualChunksOption = (id: string) => {
|
|
71
49
|
if (id.includes('vitrify/src/vite/')) {
|
|
72
50
|
const name = id.split('/').at(-1)?.split('.').at(0)
|
|
73
51
|
if (name && manualChunkNames.includes(name)) return name
|
|
52
|
+
} else if (
|
|
53
|
+
VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))
|
|
54
|
+
) {
|
|
55
|
+
return VIRTUAL_MODULES.find((name) => id.includes(name))
|
|
74
56
|
} else if (id.includes('node_modules')) {
|
|
75
57
|
return 'vendor'
|
|
76
58
|
}
|
|
@@ -79,7 +61,9 @@ const manualChunks = (id: string) => {
|
|
|
79
61
|
export const VIRTUAL_MODULES = [
|
|
80
62
|
'virtual:vitrify-hooks',
|
|
81
63
|
'virtual:global-css',
|
|
82
|
-
'virtual:static-imports'
|
|
64
|
+
'virtual:static-imports',
|
|
65
|
+
'vitrify.sass',
|
|
66
|
+
'vitrify.css'
|
|
83
67
|
]
|
|
84
68
|
|
|
85
69
|
async function bundleConfigFile(
|
|
@@ -148,7 +132,8 @@ export const baseConfig = async ({
|
|
|
148
132
|
command = 'build',
|
|
149
133
|
mode = 'production',
|
|
150
134
|
framework = 'vue',
|
|
151
|
-
pwa = false
|
|
135
|
+
pwa = false,
|
|
136
|
+
debug = false
|
|
152
137
|
}: {
|
|
153
138
|
ssr?: 'client' | 'server' | 'ssg' | 'fastify'
|
|
154
139
|
appDir?: URL
|
|
@@ -158,6 +143,7 @@ export const baseConfig = async ({
|
|
|
158
143
|
mode?: 'production' | 'development'
|
|
159
144
|
framework?: 'vue'
|
|
160
145
|
pwa?: boolean
|
|
146
|
+
debug?: boolean
|
|
161
147
|
}): Promise<InlineConfig> => {
|
|
162
148
|
const { getAppDir, getCliDir, getCliViteDir, getSrcDir, getCwd } =
|
|
163
149
|
await import('./app-urls.js')
|
|
@@ -263,6 +249,7 @@ export const baseConfig = async ({
|
|
|
263
249
|
let staticImports: StaticImports
|
|
264
250
|
let sassVariables: Record<string, string>
|
|
265
251
|
let additionalData: string[]
|
|
252
|
+
let globalSass: string[]
|
|
266
253
|
let serverModules: string[] = internalServerModules
|
|
267
254
|
|
|
268
255
|
if (vitrifyConfig.vitrify?.ssr?.serverModules)
|
|
@@ -305,20 +292,21 @@ export const baseConfig = async ({
|
|
|
305
292
|
globalCss = config.vitrify?.globalCss || []
|
|
306
293
|
staticImports = config.vitrify?.staticImports || {}
|
|
307
294
|
sassVariables = config.vitrify?.sass?.variables || {}
|
|
295
|
+
globalSass = config.vitrify?.sass?.global || []
|
|
308
296
|
additionalData = config.vitrify?.sass?.additionalData || []
|
|
309
297
|
|
|
310
298
|
return {
|
|
311
299
|
css: {
|
|
312
300
|
preprocessorOptions: {
|
|
313
|
-
sass: {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
301
|
+
// sass: {
|
|
302
|
+
// additionalData: [
|
|
303
|
+
// ...Object.entries(sassVariables).map(
|
|
304
|
+
// ([key, value]) => `${key}: ${value}`
|
|
305
|
+
// )
|
|
306
|
+
// // ...additionalData
|
|
307
|
+
// // config.css?.preprocessorOptions?.sass.additionalData
|
|
308
|
+
// ].join('\n')
|
|
309
|
+
// }
|
|
322
310
|
}
|
|
323
311
|
}
|
|
324
312
|
}
|
|
@@ -330,8 +318,7 @@ export const baseConfig = async ({
|
|
|
330
318
|
}
|
|
331
319
|
},
|
|
332
320
|
resolveId(id) {
|
|
333
|
-
if (VIRTUAL_MODULES.includes(id))
|
|
334
|
-
return { id, moduleSideEffects: false }
|
|
321
|
+
if (VIRTUAL_MODULES.includes(id)) return { id }
|
|
335
322
|
return
|
|
336
323
|
},
|
|
337
324
|
transform: (code, id) => {
|
|
@@ -379,6 +366,15 @@ export const baseConfig = async ({
|
|
|
379
366
|
([key, value]) => `export { ${value.join(',')} } from '${key}';`
|
|
380
367
|
)
|
|
381
368
|
.join('\n')}`
|
|
369
|
+
} else if (id === 'vitrify.sass') {
|
|
370
|
+
return [
|
|
371
|
+
...Object.entries(sassVariables).map(
|
|
372
|
+
([key, value]) => `${key}: ${value}`
|
|
373
|
+
),
|
|
374
|
+
...globalSass.map((sass) => `@import '${sass}'`)
|
|
375
|
+
].join('\n')
|
|
376
|
+
} else if (id === 'vitrify.css') {
|
|
377
|
+
return `${globalCss.map((css) => `import '${css}'`).join('\n')}`
|
|
382
378
|
}
|
|
383
379
|
return null
|
|
384
380
|
}
|
|
@@ -438,6 +434,8 @@ export const baseConfig = async ({
|
|
|
438
434
|
}
|
|
439
435
|
}
|
|
440
436
|
})
|
|
437
|
+
|
|
438
|
+
if (debug) plugins.push(visualizer())
|
|
441
439
|
}
|
|
442
440
|
|
|
443
441
|
const alias: Alias[] = [
|
|
@@ -471,6 +469,7 @@ export const baseConfig = async ({
|
|
|
471
469
|
|
|
472
470
|
if (ssr === 'server') {
|
|
473
471
|
rollupOptions = {
|
|
472
|
+
...rollupOptions,
|
|
474
473
|
input: [
|
|
475
474
|
new URL('ssr/entry-server.ts', frameworkDir).pathname,
|
|
476
475
|
new URL('ssr/prerender.ts', frameworkDir).pathname,
|
|
@@ -478,7 +477,7 @@ export const baseConfig = async ({
|
|
|
478
477
|
],
|
|
479
478
|
external,
|
|
480
479
|
output: {
|
|
481
|
-
minifyInternalExports:
|
|
480
|
+
minifyInternalExports: !debug,
|
|
482
481
|
entryFileNames: '[name].mjs',
|
|
483
482
|
chunkFileNames: '[name].mjs',
|
|
484
483
|
format: 'es',
|
|
@@ -500,6 +499,7 @@ export const baseConfig = async ({
|
|
|
500
499
|
]
|
|
501
500
|
} else if (ssr === 'fastify') {
|
|
502
501
|
rollupOptions = {
|
|
502
|
+
...rollupOptions,
|
|
503
503
|
input: [new URL('server.ts', fastifyDir).pathname],
|
|
504
504
|
external,
|
|
505
505
|
output: {
|
|
@@ -524,13 +524,14 @@ export const baseConfig = async ({
|
|
|
524
524
|
]
|
|
525
525
|
} else {
|
|
526
526
|
rollupOptions = {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
527
|
+
...rollupOptions,
|
|
528
|
+
// input: [
|
|
529
|
+
// new URL('index.html', frameworkDir).pathname
|
|
530
|
+
// // new URL('csr/server.ts', frameworkDir).pathname
|
|
531
|
+
// ],
|
|
531
532
|
external,
|
|
532
533
|
output: {
|
|
533
|
-
minifyInternalExports:
|
|
534
|
+
minifyInternalExports: !debug,
|
|
534
535
|
entryFileNames: '[name].mjs',
|
|
535
536
|
chunkFileNames: '[name].mjs',
|
|
536
537
|
format: 'es',
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers'
|
|
14
14
|
import type { VitrifyPlugin } from './index.js'
|
|
15
15
|
import { getPkgJsonDir } from '../app-urls.js'
|
|
16
|
+
|
|
16
17
|
import { resolve } from 'import-meta-resolve'
|
|
17
18
|
|
|
18
19
|
export interface QuasarConf {
|
|
@@ -92,11 +93,17 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
92
93
|
const { ssr } = options || {}
|
|
93
94
|
code = code
|
|
94
95
|
.replaceAll('__QUASAR_SSR__', ssr ? ssr.toString() : 'false')
|
|
95
|
-
.replaceAll(
|
|
96
|
-
|
|
96
|
+
.replaceAll(
|
|
97
|
+
'__QUASAR_SSR_SERVER__',
|
|
98
|
+
ssr ? 'import.meta.env.SSR' : 'false'
|
|
99
|
+
)
|
|
100
|
+
.replaceAll(
|
|
101
|
+
'__QUASAR_SSR_CLIENT__',
|
|
102
|
+
ssr ? '!import.meta.env.SSR' : 'false'
|
|
103
|
+
)
|
|
97
104
|
.replaceAll(
|
|
98
105
|
'__QUASAR_SSR_PWA__',
|
|
99
|
-
pwa ? '!import.meta.env.SSR' : 'false'
|
|
106
|
+
ssr && pwa ? '!import.meta.env.SSR' : 'false'
|
|
100
107
|
)
|
|
101
108
|
|
|
102
109
|
return code
|
|
@@ -161,7 +168,8 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
161
168
|
onRendered: [injectSsrContext]
|
|
162
169
|
},
|
|
163
170
|
sass: {
|
|
164
|
-
|
|
171
|
+
global: ['quasar/src/css/index.sass']
|
|
172
|
+
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
175
|
}
|
|
@@ -225,7 +233,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
225
233
|
urls?.packages?.quasar
|
|
226
234
|
).pathname
|
|
227
235
|
},
|
|
228
|
-
|
|
229
236
|
{
|
|
230
237
|
find: 'quasar/directives',
|
|
231
238
|
replacement: new URL(
|
|
@@ -237,20 +244,17 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
237
244
|
find: 'quasar/src',
|
|
238
245
|
replacement: new URL('src/', urls?.packages?.quasar).pathname
|
|
239
246
|
},
|
|
240
|
-
{
|
|
241
|
-
find: new RegExp('^quasar$'),
|
|
242
|
-
replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
243
|
-
.pathname
|
|
244
|
-
},
|
|
245
247
|
// {
|
|
246
|
-
// find: 'quasar',
|
|
247
|
-
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
248
|
+
// find: new RegExp('^quasar$'),
|
|
249
|
+
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
250
|
+
// .pathname
|
|
248
251
|
// },
|
|
249
252
|
{
|
|
250
253
|
find: `@quasar/extras`,
|
|
251
254
|
replacement: new URL('.', urls?.packages?.['@quasar/extras'])
|
|
252
255
|
.pathname
|
|
253
256
|
}
|
|
257
|
+
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
254
258
|
]
|
|
255
259
|
},
|
|
256
260
|
define: {
|
|
@@ -272,7 +276,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
272
276
|
},
|
|
273
277
|
{
|
|
274
278
|
name: 'quasar-virtual-modules',
|
|
275
|
-
enforce: '
|
|
279
|
+
enforce: 'pre',
|
|
276
280
|
config: async (config, env) => ({
|
|
277
281
|
resolve: {
|
|
278
282
|
alias: [
|
|
@@ -284,8 +288,8 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
284
288
|
switch (id) {
|
|
285
289
|
case 'virtual:quasar-plugins':
|
|
286
290
|
return 'virtual:quasar-plugins'
|
|
287
|
-
case '
|
|
288
|
-
return { id: '
|
|
291
|
+
case 'quasar':
|
|
292
|
+
return { id: 'quasar', moduleSideEffects: false }
|
|
289
293
|
default:
|
|
290
294
|
return
|
|
291
295
|
}
|
|
@@ -293,7 +297,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
293
297
|
load(id) {
|
|
294
298
|
if (id === 'virtual:quasar-plugins') {
|
|
295
299
|
return `export { ${plugins.join(',')} } from 'quasar'`
|
|
296
|
-
} else if (id === '
|
|
300
|
+
} else if (id === 'quasar') {
|
|
297
301
|
return `export * from 'quasar/src/plugins.js';
|
|
298
302
|
export * from 'quasar/src/components.js';
|
|
299
303
|
export * from 'quasar/src/composables.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { FastifyInstance } from 'fastify'
|
|
2
1
|
import type { Alias, UserConfig } from 'vite'
|
|
3
2
|
import type { QuasarConf } from './plugins/quasar.js'
|
|
4
3
|
import type { ComponentInternalInstance } from '@vue/runtime-core'
|
|
@@ -72,6 +71,7 @@ export interface VitrifyConfig extends UserConfig {
|
|
|
72
71
|
sass?: {
|
|
73
72
|
variables?: Record<string, string>
|
|
74
73
|
additionalData?: string[]
|
|
74
|
+
global?: string[]
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Product name of the application. Will be used for the HTML title tag
|