live-server.nvim icon indicating copy to clipboard operation
live-server.nvim copied to clipboard

[Bug] can't handle relative path properly

Open shellRaining opened this issue 1 year ago • 7 comments

Info

  • Operating System: Mac OS
  • nvim --version: 0.9.4
  • Node package manager: v21.5.0
  • <node-package-manager> --version: 10.2.4
  • live-server --version: live-server 1.2.2

Configuration

use lazy and just use config = true

    { "barrett-ruth/live-server.nvim", build = "npm install -g live-server", config = true },

Description

import { App } from "./App.js";
import { createApp } from "../../lib/miniVue.esm.js";

I am sure that miniVue.esm.js is exist and can use gf to jump to this file, however, browser report that

GET http://127.0.0.1:8080/lib/miniVue.esm.js net::ERR_ABORTED 404 (Not Found)

the same plugin in vscode is work properly, so I guess it is a bug of this plugin

shellRaining avatar Dec 21 '23 07:12 shellRaining

Hey, sorry about the issue - can you provide a boilerplate so I can duplicate the error?

Thanks.

barrett-ruth avatar Dec 21 '23 17:12 barrett-ruth

Exact same setup works for me.

v0ry avatar Feb 01 '24 20:02 v0ry

Info

  • Operating System: Mac OS
  • nvim --version: 0.9.4
  • Node package manager: v21.5.0
  • <node-package-manager> --version: 10.2.4
  • live-server --version: live-server 1.2.2

Configuration

use lazy and just use config = true

    { "barrett-ruth/live-server.nvim", build = "npm install -g live-server", config = true },

Description

import { App } from "./App.js";
import { createApp } from "../../lib/miniVue.esm.js";

I am sure that miniVue.esm.js is exist and can use gf to jump to this file, however, browser report that

GET http://127.0.0.1:8080/lib/miniVue.esm.js net::ERR_ABORTED 404 (Not Found)

the same plugin in vscode is work properly, so I guess it is a bug of this plugin

https://www.npmjs.com/package/live-server checkout the follwoing

v0ry avatar Feb 01 '24 20:02 v0ry

@shellRaining. Thanks for the response v0ry as well.

barrett-ruth avatar Feb 03 '24 20:02 barrett-ruth

Hey there, I am facing a similar issue when trying to link css files to my html.

If the file is in (or is a child of) the current directory the css will apply to my webpage, however when trying to move up the directory tree (i.e. using ../) the css is no longer applied.

I found a similar issue with the vscode plugin and someone hinted that it may be due to the web root of the live server.

However, I know for a fact that the above (css file out of scope of html) is not an issue in vscode as I have tested it. So this brings me to wonder how was it configured in vscode and how I could adapt it to this plugin.

kxrur avatar Feb 16 '24 01:02 kxrur

@kxrur thanks for the update. how does this work with using live-server via the CLI (can you start it in a different directory or with different arguments and it'll work)? From what you linked, it seems like that could be a configuration error/confusion. Can you provide screenshots/config for this (basic index.html, styles/index.css or something like that) so I can replicate and fix this issue?

barrett-ruth avatar Feb 16 '24 20:02 barrett-ruth

Sure thing! I am pretty new to this so I did not have the courage to go through the various arguments of live-server in the CLI, hopefully this below is eough.

Info

  • Operating System: Linux (Ubuntu 22.04.3 LTS)
  • nvim --version: v0.10.0
  • Node package manager: npm
  • <node-package-manager> --version: 10.2.4
  • live-server --version: 1.2.2

Configuration

  "barrett-ruth/live-server.nvim",
  build = "npm add -g live-server",
  cmd = { "LiveServerStart", "LiveServerStop" },
  config = true,
  keys = {
    { "<leader>cp", "<cmd>LiveServerToggle<cr>", desc = "Start live server" },
  },

Description

given a set-up with the following structure:

.
├── assets
│   └── icon.svg
├── css
│   └── style.css
└── html
    └── index.html

and the following index and style files respectively

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title></title>
    <link href="../css/style.css" rel="stylesheet" />
  </head>
  <body>
    <p>Text</p>
    <img src="../assets/icon.svg" alt="icon" />
  </body>
</html>
p {
  color: pink;
}
img {
  width: 20px;
}
  • Test 1: run LiveServerStart from nvim's command line image

  • Test 2: run live-server from a terminal image -- > chose html image

  • Test 3: run cd html/ && live-server from a terminal image

  • Test 4: click on 'Go Live' in vscode image

kxrur avatar Feb 17 '24 05:02 kxrur

@shellRaining reopen if still occurring.

barrett-ruth avatar Aug 03 '24 22:08 barrett-ruth