vitrify 0.25.4 → 0.25.6
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 +2 -2
- package/dist/bin/cli.js +4 -1
- package/dist/bin/dev.js +30 -18
- package/dist/bin/run.js +2 -1
- package/dist/frameworks/vue/prerender.js +3 -2
- package/dist/index.js +22 -16
- package/dist/types/bin/dev.d.ts +2 -2
- package/package.json +1 -1
- package/src/node/app-urls.ts +2 -2
- package/src/node/bin/cli.ts +5 -2
- package/src/node/bin/dev.ts +41 -20
- package/src/node/bin/run.ts +4 -1
- package/src/node/frameworks/vue/prerender.ts +3 -2
- package/src/node/index.ts +22 -17
package/dist/app-urls.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// import { resolve } from 'import-meta-resolve'
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
4
4
|
export const resolve = (packageName, base, counter = 0) => {
|
|
5
5
|
const packageUrl = new URL(`./node_modules/${packageName}/`, base);
|
|
6
6
|
if (existsSync(fileURLToPath(packageUrl))) {
|
|
@@ -17,7 +17,7 @@ export const getPkgJsonDir = (dir) => {
|
|
|
17
17
|
}
|
|
18
18
|
return getPkgJsonDir(new URL('..', dir));
|
|
19
19
|
};
|
|
20
|
-
export const getAppDir = (dir) => getPkgJsonDir(dir ??
|
|
20
|
+
export const getAppDir = (dir) => getPkgJsonDir(dir ?? pathToFileURL(`${process.cwd()}/`));
|
|
21
21
|
export const getCliDir = () => getPkgJsonDir(new URL('./', import.meta.url));
|
|
22
22
|
export const getCliViteDir = (cliDir) => new URL('src/vite/', cliDir);
|
|
23
23
|
export const getSrcDir = (appDir) => new URL('src/', appDir);
|
package/dist/bin/cli.js
CHANGED
|
@@ -17,6 +17,7 @@ cli
|
|
|
17
17
|
.option('--productName [productName]', 'Product name')
|
|
18
18
|
.option('--debug', 'Debug build')
|
|
19
19
|
.action(async (options) => {
|
|
20
|
+
console.log('test');
|
|
20
21
|
const { build } = await import('./build.js');
|
|
21
22
|
let appDir;
|
|
22
23
|
let prerender;
|
|
@@ -27,8 +28,10 @@ cli
|
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
29
30
|
appDir = getAppDir();
|
|
31
|
+
console.log(appDir);
|
|
30
32
|
}
|
|
31
33
|
const baseOutDir = parsePath(options.outDir, appDir) || new URL('dist/', appDir);
|
|
34
|
+
console.log(new URL('./', appDir).href);
|
|
32
35
|
const args = {
|
|
33
36
|
base: options.base,
|
|
34
37
|
appDir,
|
|
@@ -73,7 +76,7 @@ cli
|
|
|
73
76
|
...args,
|
|
74
77
|
outDir: fileURLToPath(new URL('ssr/server/', baseOutDir))
|
|
75
78
|
});
|
|
76
|
-
({ prerender } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).
|
|
79
|
+
({ prerender } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).href));
|
|
77
80
|
const { template, manifest, render, getRoutes, onAppRendered, onTemplateRendered } = await loadSSRAssets({
|
|
78
81
|
mode: 'ssg',
|
|
79
82
|
distDir: baseOutDir
|
package/dist/bin/dev.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveConfig } from 'vite';
|
|
1
2
|
import { baseConfig } from '../index.js';
|
|
2
3
|
import fastify from 'fastify';
|
|
3
4
|
import { fastifySsrPlugin } from '../frameworks/vue/fastify-ssr-plugin.js';
|
|
@@ -22,36 +23,47 @@ ssr, framework = 'vue', host, appDir, publicDir, base }) {
|
|
|
22
23
|
ssrMode = 'server';
|
|
23
24
|
if (ssr === 'fastify')
|
|
24
25
|
ssrMode = 'fastify';
|
|
25
|
-
config = await baseConfig({
|
|
26
|
-
framework,
|
|
27
|
-
ssr: ssrMode,
|
|
28
|
-
command: 'dev',
|
|
29
|
-
mode: 'development',
|
|
30
|
-
appDir,
|
|
31
|
-
publicDir,
|
|
32
|
-
base
|
|
33
|
-
});
|
|
34
26
|
const wsPort = await getFirstOpenPort(24678);
|
|
35
27
|
if (config.server?.https) {
|
|
36
28
|
exitLogs.push(`[warning] HTTPS mode enabled. Visit https://{hostname}:${wsPort} to enable a security exception for HMR.`);
|
|
37
29
|
}
|
|
30
|
+
config = await resolveConfig({
|
|
31
|
+
...(await baseConfig({
|
|
32
|
+
framework,
|
|
33
|
+
ssr: ssrMode,
|
|
34
|
+
command: 'dev',
|
|
35
|
+
mode: 'development',
|
|
36
|
+
appDir,
|
|
37
|
+
publicDir,
|
|
38
|
+
base
|
|
39
|
+
})),
|
|
40
|
+
server: {
|
|
41
|
+
host,
|
|
42
|
+
port
|
|
43
|
+
// hmr: {
|
|
44
|
+
// protocol: config.server?.https ? 'wss' : 'ws',
|
|
45
|
+
// port: wsPort
|
|
46
|
+
// }
|
|
47
|
+
}
|
|
48
|
+
}, 'serve');
|
|
38
49
|
const vitrifyDevServer = await (await import('vite')).createServer({
|
|
50
|
+
// @ts-expect-error configFile is defined more than once
|
|
39
51
|
configFile: false,
|
|
40
52
|
...config,
|
|
41
53
|
logLevel,
|
|
42
54
|
define: {
|
|
43
55
|
...config.define,
|
|
44
56
|
__HOST__: `'${host}'`
|
|
45
|
-
},
|
|
46
|
-
server: {
|
|
47
|
-
...config.server,
|
|
48
|
-
host,
|
|
49
|
-
port,
|
|
50
|
-
hmr: {
|
|
51
|
-
protocol: config.server?.https ? 'wss' : 'ws',
|
|
52
|
-
port: wsPort
|
|
53
|
-
}
|
|
54
57
|
}
|
|
58
|
+
// server: {
|
|
59
|
+
// ...config.server,
|
|
60
|
+
// host,
|
|
61
|
+
// port,
|
|
62
|
+
// hmr: {
|
|
63
|
+
// protocol: config.server?.https ? 'wss' : 'ws',
|
|
64
|
+
// port: wsPort
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
55
67
|
});
|
|
56
68
|
return vitrifyDevServer;
|
|
57
69
|
}
|
package/dist/bin/run.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import readline from 'readline';
|
|
3
3
|
import { getAppDir, getCliDir, getProjectURLs } from '../app-urls.js';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
4
5
|
const rl = readline.createInterface({
|
|
5
6
|
input: process.stdin,
|
|
6
7
|
output: process.stdout
|
|
@@ -10,7 +11,7 @@ export async function run(filePath) {
|
|
|
10
11
|
const appDir = getAppDir();
|
|
11
12
|
const cliDir = getCliDir();
|
|
12
13
|
const projectURLs = getProjectURLs(appDir, cliDir);
|
|
13
|
-
const pkg = JSON.parse((await fs.readFile(projectURLs.cli('package.json'), 'utf-8')).toString());
|
|
14
|
+
const pkg = JSON.parse((await fs.readFile(fileURLToPath(projectURLs.cli('package.json')), 'utf-8')).toString());
|
|
14
15
|
if (!run)
|
|
15
16
|
throw new Error(`${filePath} does not have an export named run. Aborting...`);
|
|
16
17
|
rl.question(`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises as fs, mkdirSync } from 'fs';
|
|
2
2
|
import { routesToPaths } from '../../helpers/routes.js';
|
|
3
3
|
import { renderHtml } from './fastify-ssr-plugin.js';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
4
5
|
export const prerender = async ({ outDir, template, manifest, render, routes, onTemplateRendered }) => {
|
|
5
6
|
const promises = [];
|
|
6
7
|
const paths = routesToPaths(routes).filter((i) => !i.includes(':') && !i.includes('*'));
|
|
@@ -13,8 +14,8 @@ export const prerender = async ({ outDir, template, manifest, render, routes, on
|
|
|
13
14
|
});
|
|
14
15
|
for (const url of paths) {
|
|
15
16
|
const directoryUrl = new URL(url.split('/').slice(0, -1).join('/'), `file://${outDir}`);
|
|
16
|
-
if (!existsSync(directoryUrl
|
|
17
|
-
mkdirSync(directoryUrl
|
|
17
|
+
if (!existsSync(fileURLToPath(directoryUrl))) {
|
|
18
|
+
mkdirSync(fileURLToPath(directoryUrl), { recursive: true });
|
|
18
19
|
}
|
|
19
20
|
const filename = (url.endsWith('/') ? 'index' : url.replace(/^\//g, '')) + '.html';
|
|
20
21
|
console.log(`Generating ${filename}`);
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,17 @@ const manualChunkNames = [
|
|
|
37
37
|
'server'
|
|
38
38
|
];
|
|
39
39
|
const moduleChunks = {
|
|
40
|
-
vue: [
|
|
40
|
+
vue: [
|
|
41
|
+
'vue',
|
|
42
|
+
'@vue',
|
|
43
|
+
'vue-router',
|
|
44
|
+
'pinia',
|
|
45
|
+
'@pinia/colada',
|
|
46
|
+
'@vue/devtools-api',
|
|
47
|
+
'@vueuse/core',
|
|
48
|
+
'@vueuse/metadata',
|
|
49
|
+
'@vueuse/shared'
|
|
50
|
+
],
|
|
41
51
|
quasar: ['quasar'],
|
|
42
52
|
atQuasar: ['@quasar']
|
|
43
53
|
};
|
|
@@ -133,16 +143,19 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
133
143
|
publicDir = new URL('public/', appDir);
|
|
134
144
|
let rawVitrifyConfig;
|
|
135
145
|
let vitrifyConfig;
|
|
146
|
+
console.log(appDir);
|
|
136
147
|
try {
|
|
137
148
|
if (fs.existsSync(fileURLToPath(new URL('vitrify.config.ts', appDir)))) {
|
|
138
149
|
const configPath = fileURLToPath(new URL('vitrify.config.ts', appDir));
|
|
139
150
|
const bundledConfig = await bundleConfigFile(fileURLToPath(new URL('vitrify.config.ts', appDir)));
|
|
140
151
|
fs.writeFileSync(configPath + '.js', bundledConfig.code);
|
|
152
|
+
console.log('kljsdflkjdsf');
|
|
153
|
+
console.log(configPath);
|
|
141
154
|
rawVitrifyConfig = (await import('file://' + configPath + '.js')).default;
|
|
142
155
|
fs.unlinkSync(configPath + '.js');
|
|
143
156
|
}
|
|
144
157
|
else {
|
|
145
|
-
rawVitrifyConfig = (await import(
|
|
158
|
+
rawVitrifyConfig = (await import(new URL('vitrify.config.js', appDir).href)).default;
|
|
146
159
|
}
|
|
147
160
|
if (typeof rawVitrifyConfig === 'function') {
|
|
148
161
|
vitrifyConfig = await rawVitrifyConfig({ mode, command });
|
|
@@ -326,7 +339,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
326
339
|
.replaceAll('-', '')
|
|
327
340
|
.replaceAll('_', '')
|
|
328
341
|
.replaceAll('+', '');
|
|
329
|
-
return `import ${varName} from '${new URL(url, appDir).
|
|
342
|
+
return `import ${varName} from '${new URL(url, appDir).href}'; onAppMounted.push(${varName});`;
|
|
330
343
|
})
|
|
331
344
|
.join('\n')}
|
|
332
345
|
export const onAppRendered = [${onAppRenderedHooks
|
|
@@ -342,7 +355,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
342
355
|
.replaceAll('-', '')
|
|
343
356
|
.replaceAll('_', '')
|
|
344
357
|
.replaceAll('+', '');
|
|
345
|
-
return `import ${varName} from '${new URL(url, appDir).
|
|
358
|
+
return `import ${varName} from '${new URL(url, appDir).href}'; onAppRendered.push(${varName});`;
|
|
346
359
|
})
|
|
347
360
|
.join('\n')}
|
|
348
361
|
export const onTemplateRendered = [${onTemplateRenderedHooks
|
|
@@ -358,7 +371,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
358
371
|
.replaceAll('-', '')
|
|
359
372
|
.replaceAll('_', '')
|
|
360
373
|
.replaceAll('+', '');
|
|
361
|
-
return `import ${varName} from '${new URL(url, appDir).
|
|
374
|
+
return `import ${varName} from '${new URL(url, appDir).href}'; onTemplateRendered.push(${varName});`;
|
|
362
375
|
})
|
|
363
376
|
.join('\n')}
|
|
364
377
|
export const onAppCreated = [${OnAppCreatedHooks.map((fn) => `${String(fn)}`).join(', ')}]
|
|
@@ -372,7 +385,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
372
385
|
.replaceAll('-', '')
|
|
373
386
|
.replaceAll('_', '')
|
|
374
387
|
.replaceAll('+', '');
|
|
375
|
-
return `import ${varName} from '${new URL(url, appDir).
|
|
388
|
+
return `import ${varName} from '${new URL(url, appDir).href}'; onAppCreated.push(${varName});`;
|
|
376
389
|
})
|
|
377
390
|
.join('\n')}
|
|
378
391
|
export const onSetup = []
|
|
@@ -386,7 +399,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
386
399
|
.replaceAll('-', '')
|
|
387
400
|
.replaceAll('_', '')
|
|
388
401
|
.replaceAll('+', '');
|
|
389
|
-
return `import ${varName} from '${new URL(url, appDir).
|
|
402
|
+
return `import ${varName} from '${new URL(url, appDir).href}'; onSetup.push(${varName});`;
|
|
390
403
|
})
|
|
391
404
|
.join('\n')}`;
|
|
392
405
|
}
|
|
@@ -473,14 +486,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
473
486
|
default:
|
|
474
487
|
entry = fileURLToPath(new URL('csr/entry.ts', frameworkDir));
|
|
475
488
|
}
|
|
476
|
-
|
|
477
|
-
if (process.platform === 'win32') {
|
|
478
|
-
const split = entry.split('node_modules');
|
|
479
|
-
entryScript = `<script type="module" src="node_modules${split.at(-1)}"></script>`;
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
entryScript = `<script type="module" src="${entry}"></script>`;
|
|
483
|
-
}
|
|
489
|
+
const entryScript = `<script type="module" src="${entry}"></script>`;
|
|
484
490
|
html = appendToBody(entryScript, html);
|
|
485
491
|
if (productName)
|
|
486
492
|
html = addOrReplaceTitle(productName, html);
|
|
@@ -650,7 +656,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
650
656
|
// environments: {
|
|
651
657
|
// },
|
|
652
658
|
server: {
|
|
653
|
-
https: vitrifyConfig.server?.https,
|
|
659
|
+
// https: vitrifyConfig.server?.https,
|
|
654
660
|
// middlewareMode: mode === 'ssr' ? 'ssr' : undefined,
|
|
655
661
|
middlewareMode: ssr ? true : false,
|
|
656
662
|
fs: {
|
package/dist/types/bin/dev.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LogLevel, type ViteDevServer, ResolvedConfig } from 'vite';
|
|
2
2
|
import type { Server } from 'net';
|
|
3
3
|
import type { FastifyInstance } from 'fastify';
|
|
4
4
|
declare module 'vite' {
|
|
@@ -28,6 +28,6 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
|
|
|
28
28
|
}): Promise<{
|
|
29
29
|
app: FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> | undefined;
|
|
30
30
|
server: Server;
|
|
31
|
-
config:
|
|
31
|
+
config: ResolvedConfig;
|
|
32
32
|
vite: ViteDevServer;
|
|
33
33
|
}>;
|
package/package.json
CHANGED
package/src/node/app-urls.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// import { resolve } from 'import-meta-resolve'
|
|
2
2
|
import { existsSync } from 'fs'
|
|
3
|
-
import { fileURLToPath } from 'url'
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'url'
|
|
4
4
|
|
|
5
5
|
export const resolve = (packageName: string, base: URL, counter = 0): URL => {
|
|
6
6
|
const packageUrl = new URL(`./node_modules/${packageName}/`, base)
|
|
@@ -20,7 +20,7 @@ export const getPkgJsonDir = (dir: URL): URL => {
|
|
|
20
20
|
return getPkgJsonDir(new URL('..', dir))
|
|
21
21
|
}
|
|
22
22
|
export const getAppDir = (dir?: URL) =>
|
|
23
|
-
getPkgJsonDir(dir ??
|
|
23
|
+
getPkgJsonDir(dir ?? pathToFileURL(`${process.cwd()}/`))
|
|
24
24
|
export const getCliDir = () => getPkgJsonDir(new URL('./', import.meta.url))
|
|
25
25
|
export const getCliViteDir = (cliDir: URL) => new URL('src/vite/', cliDir)
|
|
26
26
|
export const getSrcDir = (appDir: URL) => new URL('src/', appDir)
|
package/src/node/bin/cli.ts
CHANGED
|
@@ -21,6 +21,7 @@ cli
|
|
|
21
21
|
.option('--productName [productName]', 'Product name')
|
|
22
22
|
.option('--debug', 'Debug build')
|
|
23
23
|
.action(async (options) => {
|
|
24
|
+
console.log('test')
|
|
24
25
|
const { build } = await import('./build.js')
|
|
25
26
|
let appDir: URL
|
|
26
27
|
let prerender
|
|
@@ -29,11 +30,13 @@ cli
|
|
|
29
30
|
appDir = new URL(`file://${options.appDir}`)
|
|
30
31
|
} else {
|
|
31
32
|
appDir = getAppDir()
|
|
33
|
+
console.log(appDir)
|
|
32
34
|
}
|
|
33
|
-
|
|
34
35
|
const baseOutDir =
|
|
35
36
|
parsePath(options.outDir, appDir) || new URL('dist/', appDir)
|
|
36
37
|
|
|
38
|
+
console.log(new URL('./', appDir).href)
|
|
39
|
+
|
|
37
40
|
const args: {
|
|
38
41
|
base: string
|
|
39
42
|
appDir?: URL
|
|
@@ -86,7 +89,7 @@ cli
|
|
|
86
89
|
outDir: fileURLToPath(new URL('ssr/server/', baseOutDir))
|
|
87
90
|
})
|
|
88
91
|
;({ prerender } = await import(
|
|
89
|
-
new URL('ssr/server/prerender.mjs', baseOutDir).
|
|
92
|
+
new URL('ssr/server/prerender.mjs', baseOutDir).href
|
|
90
93
|
))
|
|
91
94
|
|
|
92
95
|
const {
|
package/src/node/bin/dev.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
type LogLevel,
|
|
3
|
+
type InlineConfig,
|
|
4
|
+
type ViteDevServer,
|
|
5
|
+
resolveConfig,
|
|
6
|
+
ResolvedConfig
|
|
7
|
+
} from 'vite'
|
|
2
8
|
import { baseConfig } from '../index.js'
|
|
3
9
|
import type { Server } from 'net'
|
|
4
10
|
import fastify from 'fastify'
|
|
@@ -53,19 +59,10 @@ export async function createVitrifyDevServer({
|
|
|
53
59
|
)
|
|
54
60
|
|
|
55
61
|
if (!appDir) appDir = getAppDir()
|
|
56
|
-
let config: InlineConfig = {}
|
|
62
|
+
let config: InlineConfig | ResolvedConfig = {}
|
|
57
63
|
let ssrMode: 'server' | 'fastify' | undefined
|
|
58
64
|
if (ssr === 'ssr') ssrMode = 'server'
|
|
59
65
|
if (ssr === 'fastify') ssrMode = 'fastify'
|
|
60
|
-
config = await baseConfig({
|
|
61
|
-
framework,
|
|
62
|
-
ssr: ssrMode,
|
|
63
|
-
command: 'dev',
|
|
64
|
-
mode: 'development',
|
|
65
|
-
appDir,
|
|
66
|
-
publicDir,
|
|
67
|
-
base
|
|
68
|
-
})
|
|
69
66
|
|
|
70
67
|
const wsPort = await getFirstOpenPort(24678)
|
|
71
68
|
if (config.server?.https) {
|
|
@@ -74,25 +71,49 @@ export async function createVitrifyDevServer({
|
|
|
74
71
|
)
|
|
75
72
|
}
|
|
76
73
|
|
|
74
|
+
config = await resolveConfig(
|
|
75
|
+
{
|
|
76
|
+
...(await baseConfig({
|
|
77
|
+
framework,
|
|
78
|
+
ssr: ssrMode,
|
|
79
|
+
command: 'dev',
|
|
80
|
+
mode: 'development',
|
|
81
|
+
appDir,
|
|
82
|
+
publicDir,
|
|
83
|
+
base
|
|
84
|
+
})),
|
|
85
|
+
server: {
|
|
86
|
+
host,
|
|
87
|
+
port
|
|
88
|
+
// hmr: {
|
|
89
|
+
// protocol: config.server?.https ? 'wss' : 'ws',
|
|
90
|
+
// port: wsPort
|
|
91
|
+
// }
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
'serve'
|
|
95
|
+
)
|
|
96
|
+
|
|
77
97
|
const vitrifyDevServer = await (
|
|
78
98
|
await import('vite')
|
|
79
99
|
).createServer({
|
|
100
|
+
// @ts-expect-error configFile is defined more than once
|
|
80
101
|
configFile: false,
|
|
81
102
|
...config,
|
|
82
103
|
logLevel,
|
|
83
104
|
define: {
|
|
84
105
|
...config.define,
|
|
85
106
|
__HOST__: `'${host}'`
|
|
86
|
-
},
|
|
87
|
-
server: {
|
|
88
|
-
...config.server,
|
|
89
|
-
host,
|
|
90
|
-
port,
|
|
91
|
-
hmr: {
|
|
92
|
-
protocol: config.server?.https ? 'wss' : 'ws',
|
|
93
|
-
port: wsPort
|
|
94
|
-
}
|
|
95
107
|
}
|
|
108
|
+
// server: {
|
|
109
|
+
// ...config.server,
|
|
110
|
+
// host,
|
|
111
|
+
// port,
|
|
112
|
+
// hmr: {
|
|
113
|
+
// protocol: config.server?.https ? 'wss' : 'ws',
|
|
114
|
+
// port: wsPort
|
|
115
|
+
// }
|
|
116
|
+
// }
|
|
96
117
|
})
|
|
97
118
|
|
|
98
119
|
return vitrifyDevServer
|
package/src/node/bin/run.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from 'fs'
|
|
2
2
|
import readline from 'readline'
|
|
3
3
|
import { getAppDir, getCliDir, getProjectURLs } from '../app-urls.js'
|
|
4
|
+
import { fileURLToPath } from 'url'
|
|
4
5
|
|
|
5
6
|
const rl = readline.createInterface({
|
|
6
7
|
input: process.stdin,
|
|
@@ -20,7 +21,9 @@ export async function run(filePath: string) {
|
|
|
20
21
|
const cliDir = getCliDir()
|
|
21
22
|
const projectURLs = getProjectURLs(appDir, cliDir)
|
|
22
23
|
const pkg = JSON.parse(
|
|
23
|
-
(
|
|
24
|
+
(
|
|
25
|
+
await fs.readFile(fileURLToPath(projectURLs.cli('package.json')), 'utf-8')
|
|
26
|
+
).toString()
|
|
24
27
|
)
|
|
25
28
|
|
|
26
29
|
if (!run)
|
|
@@ -3,6 +3,7 @@ import type { OnTemplateRenderedHook } from 'src/node/vitrify-config.js'
|
|
|
3
3
|
import { routesToPaths } from '../../helpers/routes.js'
|
|
4
4
|
import { renderHtml } from './fastify-ssr-plugin.js'
|
|
5
5
|
import { type RouteRecordRaw } from 'vue-router'
|
|
6
|
+
import { fileURLToPath } from 'url'
|
|
6
7
|
|
|
7
8
|
export const prerender = async ({
|
|
8
9
|
outDir,
|
|
@@ -36,8 +37,8 @@ export const prerender = async ({
|
|
|
36
37
|
url.split('/').slice(0, -1).join('/'),
|
|
37
38
|
`file://${outDir}`
|
|
38
39
|
)
|
|
39
|
-
if (!existsSync(directoryUrl
|
|
40
|
-
mkdirSync(directoryUrl
|
|
40
|
+
if (!existsSync(fileURLToPath(directoryUrl))) {
|
|
41
|
+
mkdirSync(fileURLToPath(directoryUrl), { recursive: true })
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
const filename =
|
package/src/node/index.ts
CHANGED
|
@@ -67,7 +67,17 @@ const manualChunkNames = [
|
|
|
67
67
|
]
|
|
68
68
|
|
|
69
69
|
const moduleChunks = {
|
|
70
|
-
vue: [
|
|
70
|
+
vue: [
|
|
71
|
+
'vue',
|
|
72
|
+
'@vue',
|
|
73
|
+
'vue-router',
|
|
74
|
+
'pinia',
|
|
75
|
+
'@pinia/colada',
|
|
76
|
+
'@vue/devtools-api',
|
|
77
|
+
'@vueuse/core',
|
|
78
|
+
'@vueuse/metadata',
|
|
79
|
+
'@vueuse/shared'
|
|
80
|
+
],
|
|
71
81
|
quasar: ['quasar'],
|
|
72
82
|
atQuasar: ['@quasar']
|
|
73
83
|
}
|
|
@@ -201,6 +211,7 @@ export const baseConfig = async ({
|
|
|
201
211
|
let rawVitrifyConfig: VitrifyConfig | VitrifyConfigAsync
|
|
202
212
|
let vitrifyConfig: VitrifyConfig
|
|
203
213
|
|
|
214
|
+
console.log(appDir)
|
|
204
215
|
try {
|
|
205
216
|
if (fs.existsSync(fileURLToPath(new URL('vitrify.config.ts', appDir)))) {
|
|
206
217
|
const configPath = fileURLToPath(new URL('vitrify.config.ts', appDir))
|
|
@@ -209,11 +220,13 @@ export const baseConfig = async ({
|
|
|
209
220
|
)
|
|
210
221
|
fs.writeFileSync(configPath + '.js', bundledConfig.code)
|
|
211
222
|
|
|
223
|
+
console.log('kljsdflkjdsf')
|
|
224
|
+
console.log(configPath)
|
|
212
225
|
rawVitrifyConfig = (await import('file://' + configPath + '.js')).default
|
|
213
226
|
fs.unlinkSync(configPath + '.js')
|
|
214
227
|
} else {
|
|
215
228
|
rawVitrifyConfig = (
|
|
216
|
-
await import(
|
|
229
|
+
await import(new URL('vitrify.config.js', appDir).href)
|
|
217
230
|
).default
|
|
218
231
|
}
|
|
219
232
|
if (typeof rawVitrifyConfig === 'function') {
|
|
@@ -417,7 +430,7 @@ export const baseConfig = async ({
|
|
|
417
430
|
.replaceAll('+', '')
|
|
418
431
|
|
|
419
432
|
return `import ${varName} from '${
|
|
420
|
-
new URL(url, appDir).
|
|
433
|
+
new URL(url, appDir).href
|
|
421
434
|
}'; onAppMounted.push(${varName});`
|
|
422
435
|
})
|
|
423
436
|
.join('\n')}
|
|
@@ -436,7 +449,7 @@ export const baseConfig = async ({
|
|
|
436
449
|
.replaceAll('+', '')
|
|
437
450
|
|
|
438
451
|
return `import ${varName} from '${
|
|
439
|
-
new URL(url, appDir).
|
|
452
|
+
new URL(url, appDir).href
|
|
440
453
|
}'; onAppRendered.push(${varName});`
|
|
441
454
|
})
|
|
442
455
|
.join('\n')}
|
|
@@ -455,7 +468,7 @@ export const baseConfig = async ({
|
|
|
455
468
|
.replaceAll('+', '')
|
|
456
469
|
|
|
457
470
|
return `import ${varName} from '${
|
|
458
|
-
new URL(url, appDir).
|
|
471
|
+
new URL(url, appDir).href
|
|
459
472
|
}'; onTemplateRendered.push(${varName});`
|
|
460
473
|
})
|
|
461
474
|
.join('\n')}
|
|
@@ -474,7 +487,7 @@ export const baseConfig = async ({
|
|
|
474
487
|
.replaceAll('+', '')
|
|
475
488
|
|
|
476
489
|
return `import ${varName} from '${
|
|
477
|
-
new URL(url, appDir).
|
|
490
|
+
new URL(url, appDir).href
|
|
478
491
|
}'; onAppCreated.push(${varName});`
|
|
479
492
|
})
|
|
480
493
|
.join('\n')}
|
|
@@ -491,7 +504,7 @@ export const baseConfig = async ({
|
|
|
491
504
|
.replaceAll('+', '')
|
|
492
505
|
|
|
493
506
|
return `import ${varName} from '${
|
|
494
|
-
new URL(url, appDir).
|
|
507
|
+
new URL(url, appDir).href
|
|
495
508
|
}'; onSetup.push(${varName});`
|
|
496
509
|
})
|
|
497
510
|
.join('\n')}`
|
|
@@ -590,15 +603,7 @@ export const baseConfig = async ({
|
|
|
590
603
|
default:
|
|
591
604
|
entry = fileURLToPath(new URL('csr/entry.ts', frameworkDir))
|
|
592
605
|
}
|
|
593
|
-
|
|
594
|
-
if (process.platform === 'win32') {
|
|
595
|
-
const split = entry.split('node_modules')
|
|
596
|
-
entryScript = `<script type="module" src="node_modules${split.at(
|
|
597
|
-
-1
|
|
598
|
-
)}"></script>`
|
|
599
|
-
} else {
|
|
600
|
-
entryScript = `<script type="module" src="${entry}"></script>`
|
|
601
|
-
}
|
|
606
|
+
const entryScript = `<script type="module" src="${entry}"></script>`
|
|
602
607
|
html = appendToBody(entryScript, html)
|
|
603
608
|
if (productName) html = addOrReplaceTitle(productName, html)
|
|
604
609
|
return html
|
|
@@ -783,7 +788,7 @@ export const baseConfig = async ({
|
|
|
783
788
|
// environments: {
|
|
784
789
|
// },
|
|
785
790
|
server: {
|
|
786
|
-
https: vitrifyConfig.server?.https,
|
|
791
|
+
// https: vitrifyConfig.server?.https,
|
|
787
792
|
// middlewareMode: mode === 'ssr' ? 'ssr' : undefined,
|
|
788
793
|
middlewareMode: ssr ? true : false,
|
|
789
794
|
fs: {
|