Add static content to localhost
If I create a new web project in WebStorm and hit run I get a localhost:<port>/<project> URL.
Is there a way to add static content to the localhost server as it would be out on the live server? I have a public directory that holds static content that is shared amongst all my sites. I use relative paths so that way as my code moves through Integration, QA, to PROD it always works.
Any ideas?
请先登录再写评论。
Not sure I follow you... Do you mean changing built-in web server URL from 'localhost:63342/project_name' to just 'localhost:port'?
, but you can try changing hosts file to make them accessible as , where <project_name> is a name set in hosts file, like '127.0.0.1 <specified_name>', as it's written in https://youtrack.jetbrains.com/issue/WEB-8988#comment=27-577559You can't change the doc root to have the pages accessible as
Elena,
No, I am looking for a way to add a directory that has static content, to the server, so my project can access it.
Example
Directory (external to the project)
/public/css/main.css
And I have a project with a webpage that uses that main.css /webstorm workspace/test/index.html, but reference it by relative path to the server
Well ... you can always add any external folder as Additional Content Root (Settings | Project | Directories) so it will become part of the project ... but that will not help with URL as (as described above by Elena) the URL for such resource will still include project name in it (e.g. /test/public/css/main.css)
Although you may try marking that folder as a Resource Root -- may help (not so sure though)
Thanks. I will give that a try. That is what I was looking for to be able to add a directory.