-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
live server doesn't work in relative file paths #293
Comments
Just specify the type of file , Sometimes it happens if it doesn't work let me know |
@forghan89 It is working absolutely fine |
I add <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="../bootstrap/bootstrap.min.css">
</head>
<body>
<h1>Heading</h1>
<script src="../js/jquery-3.3.1.min.js"></script>
<script src="../js/popper.min.js"></script>
<script src="../bootstrap/bootstrap.min.js"></script>
</body>
</html> |
i think the problem is with your link address give your file structure
vidit
…On Sun, Feb 24, 2019, 7:57 PM forghan89 ***@***.***> wrote:
Just specify the type of file , Sometimes it happens
type="text/css"
if it doesn't work let me know
I add type="text/css" to my code But But did not work:
(This bug might be related to VScode)
`
<title>Document</title>
<link rel="stylesheet" type="text/css" href="../bootstrap/bootstrap.min.css">
<h1>Heading</h1>
<script src="../js/jquery-3.3.1.min.js"></script>
<script src="../js/popper.min.js"></script>
<script src="../bootstrap/bootstrap.min.js"></script>
`
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#293 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Agk8ZY1GyXCsoIlkXmSJ3ogenHIi9Cl5ks5vQqFTgaJpZM4a9RxE>
.
|
i countered the same problem and the reason is that liveserver does not open js and css files so you need to download liveserver extention then it will work perfect |
I encountered the same problem and it doesn't work with the So for instance, let's say we have such a structure:
assuming we are in the "/project", it will be our current path, and when we start the live server there, it (our current path, i.e., the "/project") will become our "web root", denoted by a slash ( / ) after the IP address. |
I just recently solved this issue, I found out that whenever you use relative paths in an HTML file or any other files, it uses the very root of your directory of your computer as I saw in the source code of the HTML, I used live-server via CLI, but try this in your VSCode settings if it works:
I don't know the exact settings for this since I don't use VSCode, I just researched the settings for the live-server for VSCode. As long as the root is mounted, relative paths will work. |
Thanks a lot. I had the same problem when i added js relative path |
thank you, it help me alot |
This is one of those "it's a feature, not a bug" scenarios. I needed a means to run a dev set of files while still being able to use some of the resources in root while using the CSS files in dev. This allows me to use "css/styles.css" from "./dev/index.html" and not from ".dist/css/styles.css" It's a hack, but it works for my needs. {
"liveServer.settings.root": "/dist",
"liveServer.settings.mount": [
["/", "./"], // Needed to ensure relative paths to subfolders work in /dev
["/dev", "./dev"],
["/dev/images", "./dist/images"],
],
} |
vscode-live-server doesn't work in html when add css or js relative file paths such as:
my code:
result:
The text was updated successfully, but these errors were encountered: