Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev Server - Enable --remote by Default in Containers #1780

Open
CodeMan99 opened this issue Jul 24, 2024 · 1 comment
Open

Dev Server - Enable --remote by Default in Containers #1780

CodeMan99 opened this issue Jul 24, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@CodeMan99
Copy link

Is your feature request related to a problem? Please describe.

When developing inside a devcontainer, the "Slidev: Start the dev server" option is useless due to the fact the ethernet device is not bound.

image

The dev server absolute does open the browser, but the page will never load.

Describe the solution you'd like

I would like to add is-inside-container to the dev server. When true, make --remote the default. Additionally, consider adding a new --no-remote option to turn off the binding.

Describe alternatives you've considered

Running the server manually...

@CodeMan99
Copy link
Author

Seems like the change would be something like this?

diff --git a/packages/slidev/node/cli.ts b/packages/slidev/node/cli.ts
index 1d23fe3ce110..e5953510237d 100644
--- a/packages/slidev/node/cli.ts
+++ b/packages/slidev/node/cli.ts
@@ -6,6 +6,7 @@ import * as readline from 'node:readline'
 import process from 'node:process'
 import fs from 'fs-extra'
 import openBrowser from 'open'
+import isInsideContainer from 'is-inside-container'
 import type { Argv } from 'yargs'
 import yargs from 'yargs'
 import { blue, bold, cyan, dim, gray, green, underline, yellow } from 'kolorist'
@@ -80,6 +81,7 @@ cli.command(
     .option('remote', {
       type: 'string',
       describe: 'listen public host and enable remote control',
+      default: isInsideContainer() ? "" : undefined,
     })
     .option('tunnel', {
       default: false,
diff --git a/packages/slidev/package.json b/packages/slidev/package.json
index 4ac690998f11..9991c74e7019 100644
--- a/packages/slidev/package.json
+++ b/packages/slidev/package.json
@@ -74,6 +74,7 @@
     "get-port-please": "^3.1.2",
     "global-directory": "^4.0.1",
     "htmlparser2": "^9.1.0",
+    "is-inside-container": "^1.0.0",
     "is-installed-globally": "^1.0.0",
     "jiti": "^1.21.6",
     "katex": "^0.16.11",

I am unsure how to go about testing. This is the first time I've used pnpm monorepo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants