Closed happybeing closed 5 years ago
on macOS, symlinking works fine. For example, if i run the commands below then the Documents
folder will be accessible from my web server, as expected.
$ ln -s ~/Documents
$ ws
Please post a reproduction case which fails consistently for you, I'll test it in Linux.
I'm not linking to a folder so maybe the issue is how the JavaScript file reference in a script tag is loaded.
If you put index.html and a symbolic link to a JS file (which is elsewhere on the file system) in the same folder, and reference the symlink inside a <script src='myscript.js'>
tag, ws gives a 404 for the JS file.
Hope that's clear enough! Thanks for your help.
I can't reproduce this.
I have a test harness with this folder structure:
.
├── ws-symlink
│ ├── index.html
│ ├── index.js -> ../ws-symlink-js/index.js
│ └── package-lock.json
└── ws-symlink-js
└── index.js
index.html looks like this:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="index.js"></script>
</head>
<body></body>
</html>
index.js looks like this:
console.log('OK')
I run ws
in the ws-symlink
folder and launch my browser - the index.js file is loaded via the symlink from a separate folder and OK
is written to the console log.
Tested on both macOS and Linux using Firefox, the latest node and latest local-web-server.
Thanks, I hope I haven't wasted your time. I don't have time to look again right now but will get back to you when I can.
Small update. I don't know if this is an issue with ws
or not.
It isn't the symlink that is the problem but the file. So sorry for misleading. I can't get the attached file to load using <script src="js/safenetwork.js"></script>
whereas other files in the js
folder do load. I can even load safenetwork.js if I create it with garbage (cd js && echo garbage > safenetwork.js
).
Does ws
do any checks on content before serving a JS file? I'm a bit stumped, but have attached the offending file in case you can try loading it and see if you get a 404.
I can't reproduce your issue. I created this folder structure:
.
├── index.html
└── safenetworkjs.js
Where index.html looks like this:
<!DOCTYPE html>
<html>
<head>
<title>temp</title>
<script src="safenetworkjs.js"></script>
</head>
<body>
<p>temp</p>
</body>
</html>
I ran ws
in the folder and opened the index page - everything worked correctly, the js file was loaded and evaluated.
The code you pasted refers to the wrong filename:
<script src="js/safenetwork.js"></script>
It should be:
<script src="js/safenetworkjs.js"></script>
Yes. Oh dear, BIG apology for this. I couldn't see the discrepancy. Thanks very much for your patience and sharp eyes.
Now works, including with symlinks, because I had the wrong filename. Nothing to do with ws
.
no probs, these things happen.. let me know if you find anything else!
I've a simple website that load JS scripts, and during development of some of those scripts (libraries held elsewhere) I want to use a symbolic link from the website folder to the library 'dist' file.
When I do this,
ws
gives a 404 error rather than following the symbolic link and loading the script (e.g. when referenced using<script>
inindex.html
).Is there a way to do this?
I'm on Ubuntu Linux, using
ws --version
2.5.6