2

I have the following project structure: root

 - pics
 - less
   - main
     - components
        - navbar.less

In my navbar.less I reference image from the pics folder like this:

background      : url('../pics/dtv-logo.jpg') no-repeat;

The reason for specifying the path like that is that when deployed to server the project structure will be like this one:

root
   - pics
   - css
      - index.css

So the path will correct when deployed. However, webstorm says it can't find resource, which is also correct given current folders structure. I googled and found that I can mark directory as resources. I did that but webstorm still complains. Can you explain what marking directory as resource root does and how can I solve my problem?

Example #2:

 - css
 - pics
   - assets
     - some_logo.png

Marking assets as resourceRoot and specifying URL like this '/assets/dtv-logo.jpg' still failed to resolve the path.

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
  • Marking folder as "Resource Root" will not help you here with your file references (the way you wrote them). It will help if you reference them using absolute path from the root, e.g. `'/pics/dtv-logo.jpg'` -- this way, if parent folder of `pics` will be marked as "Resource Root", it will be used as reference point when resolving such resource references/URLs – LazyOne Nov 24 '14 at 14:07
  • @LazyOne, thanks, but I don't think I understand. Given current structure if I specify url as '/pics/dtv-logo.jpg' then there is no need to mark directory as resource root because the path will be resolved correctly anyways. Can you please clarify? I also tried example #2 (specified in my question) and it still didn't work – Max Koretskyi Nov 24 '14 at 14:14
  • 1
    https://www.jetbrains.com/phpstorm/webhelp/configuring-folders-within-a-content-root.html : *"To enable PhpStorm to complete relative paths to resources under the selected folder, click the Resource Root"* This can be used when website root is NOT the same as Project Root but a subfolder (very common scenario) – LazyOne Nov 24 '14 at 14:18
  • _This can be used when website root is NOT the same as Project Root but a subfolder (very common scenario)_, yes, that's how I have project structured (php framework's files is project root, www folder is inside). So this feature will not be very useful if `www` is a project root? – Max Koretskyi Nov 24 '14 at 14:24
  • 1
    Yes and No. It still will be useful if you keep assets in multiple folders (e.g. you keep them in `/src/bundleName/resources/xxx` .. and once deployed it will be in `www/assets/xxx` for example). But yes -- if your project has simple structure with web root = project root then there will be no benefit. – LazyOne Nov 24 '14 at 14:30
  • Got you, appreciate your help! – Max Koretskyi Nov 24 '14 at 14:48
  • 1
    *"Marking `assets` as resourceRoot and specifying URL like this '/assets/dtv-logo.jpg' still failed to resolve the path."* You did it wrong: you should mark `pics` folder as Resource **Root** instead ("root" is the keyword here) -- the parent (root) for `/assets/dtv-logo.jpg`. If you want to keep as you did: then use just `/dtv-logo.jpg` – LazyOne Nov 24 '14 at 18:56
  • @LazyOne, aha, I think I got it. So if I mark `pics` as a resource root, when I specify the url like this `/assets/dtv-logo.jpg` what Php\WebStorm is doing is looking at the url and essentially replaces the first forward slash with `/pics`? – Max Koretskyi Nov 25 '14 at 08:59
  • 1
    Possible duplicate of [What is the 'Resource Root' designation for in PHPStorm? For that matter, what does PHPStorm consider to be a resource?](http://stackoverflow.com/questions/24852739/what-is-the-resource-root-designation-for-in-phpstorm-for-that-matter-what-d) – Will B. May 10 '16 at 23:44

0 Answers0