u
This commit is contained in:
@@ -6,6 +6,7 @@ import { defineConfig, searchForWorkspaceRoot, createLogger } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
import pc from 'picocolors';
|
||||
import qrcode from 'qrcode';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const useHttps = process.env.VITE_HTTPS === '1';
|
||||
@@ -94,6 +95,7 @@ const sharedResolve = {
|
||||
|
||||
const sharedServer = {
|
||||
// HTTP :4209 — HTTPS :4308 (self-signed; see npm run cert / dev:https)
|
||||
host: true,
|
||||
port: useHttps ? 4308 : 4209,
|
||||
https: httpsOptions(),
|
||||
allowedHosts: true,
|
||||
@@ -266,6 +268,20 @@ function pidReporterPlugin() {
|
||||
server.config.logger.info(
|
||||
` ${pc.green('➜')} ${pc.bold('PID')}: ${pc.cyan(process.pid)}${pmId}`,
|
||||
);
|
||||
const networkUrls = server.resolvedUrls?.network ?? [];
|
||||
const primaryUrl =
|
||||
networkUrls.find((u) => !u.includes('172.17.') && !u.includes('169.254.')) ||
|
||||
networkUrls[0] ||
|
||||
server.resolvedUrls?.local?.[0];
|
||||
if (primaryUrl) {
|
||||
qrcode.toString(primaryUrl, { type: 'terminal', small: true }, (err, qr) => {
|
||||
if (!err && qr) {
|
||||
server.config.logger.info(
|
||||
`\n ${pc.bold('Scan to open on mobile')} ${pc.dim(`(${primaryUrl})`)}:\n` + qr,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user