mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
[cli] Always set BROWSER=none env var for frontend dev server in vc dev (#8326)
Previously `vc dev` would only set this env var for "create-react-app" Framework preset, but other frameworks do the "auto-open browser window" behavior as well, and respect this env var (Docusaurus, specifically). So always set the `BROWSER=none` env var regardless of which framework preset is selected. Also simplifies the code since this was the only place `frameworkSlug` property was being used.
This commit is contained in:
@@ -61,7 +61,6 @@ export default async function dev(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let devCommand: string | undefined;
|
let devCommand: string | undefined;
|
||||||
let frameworkSlug: string | undefined;
|
|
||||||
let projectSettings: ProjectSettings | undefined;
|
let projectSettings: ProjectSettings | undefined;
|
||||||
let projectEnvs: ProjectEnvVariable[] = [];
|
let projectEnvs: ProjectEnvVariable[] = [];
|
||||||
let systemEnvValues: string[] = [];
|
let systemEnvValues: string[] = [];
|
||||||
@@ -77,10 +76,6 @@ export default async function dev(
|
|||||||
const framework = frameworks.find(f => f.slug === project.framework);
|
const framework = frameworks.find(f => f.slug === project.framework);
|
||||||
|
|
||||||
if (framework) {
|
if (framework) {
|
||||||
if (framework.slug) {
|
|
||||||
frameworkSlug = framework.slug;
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaults = framework.settings.devCommand.value;
|
const defaults = framework.settings.devCommand.value;
|
||||||
if (defaults) {
|
if (defaults) {
|
||||||
devCommand = defaults;
|
devCommand = defaults;
|
||||||
@@ -120,7 +115,6 @@ export default async function dev(
|
|||||||
const devServer = new DevServer(cwd, {
|
const devServer = new DevServer(cwd, {
|
||||||
output,
|
output,
|
||||||
devCommand,
|
devCommand,
|
||||||
frameworkSlug,
|
|
||||||
projectSettings,
|
projectSettings,
|
||||||
projectEnvs,
|
projectEnvs,
|
||||||
systemEnvValues,
|
systemEnvValues,
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ export default class DevServer {
|
|||||||
public output: Output;
|
public output: Output;
|
||||||
public proxy: httpProxy;
|
public proxy: httpProxy;
|
||||||
public envConfigs: EnvConfigs;
|
public envConfigs: EnvConfigs;
|
||||||
public frameworkSlug?: string;
|
|
||||||
public files: BuilderInputs;
|
public files: BuilderInputs;
|
||||||
public address: string;
|
public address: string;
|
||||||
public devCacheDir: string;
|
public devCacheDir: string;
|
||||||
@@ -175,7 +174,6 @@ export default class DevServer {
|
|||||||
this.address = '';
|
this.address = '';
|
||||||
this.devCommand = options.devCommand;
|
this.devCommand = options.devCommand;
|
||||||
this.projectSettings = options.projectSettings;
|
this.projectSettings = options.projectSettings;
|
||||||
this.frameworkSlug = options.frameworkSlug;
|
|
||||||
this.caseSensitive = false;
|
this.caseSensitive = false;
|
||||||
this.apiDir = null;
|
this.apiDir = null;
|
||||||
this.apiExtensions = new Set();
|
this.apiExtensions = new Set();
|
||||||
@@ -2210,7 +2208,10 @@ export default class DevServer {
|
|||||||
// Because of child process 'pipe' below, isTTY will be false.
|
// Because of child process 'pipe' below, isTTY will be false.
|
||||||
// Most frameworks use `chalk`/`supports-color` so we enable it anyway.
|
// Most frameworks use `chalk`/`supports-color` so we enable it anyway.
|
||||||
FORCE_COLOR: process.stdout.isTTY ? '1' : '0',
|
FORCE_COLOR: process.stdout.isTTY ? '1' : '0',
|
||||||
...(this.frameworkSlug === 'create-react-app' ? { BROWSER: 'none' } : {}),
|
// Prevent framework dev servers from automatically opening a web
|
||||||
|
// browser window, since it will not be the port that `vc dev`
|
||||||
|
// is listening on and thus will be missing Vercel features.
|
||||||
|
BROWSER: 'none',
|
||||||
...process.env,
|
...process.env,
|
||||||
...this.envConfigs.allEnv,
|
...this.envConfigs.allEnv,
|
||||||
PORT: `${port}`,
|
PORT: `${port}`,
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ export { VercelConfig };
|
|||||||
export interface DevServerOptions {
|
export interface DevServerOptions {
|
||||||
output: Output;
|
output: Output;
|
||||||
devCommand?: string;
|
devCommand?: string;
|
||||||
frameworkSlug?: string;
|
|
||||||
projectSettings?: ProjectSettings;
|
projectSettings?: ProjectSettings;
|
||||||
systemEnvValues?: string[];
|
systemEnvValues?: string[];
|
||||||
projectEnvs?: ProjectEnvVariable[];
|
projectEnvs?: ProjectEnvVariable[];
|
||||||
|
|||||||
Reference in New Issue
Block a user