Cannot resolve directory - Path mapping wit rewrite-rules on webserver in IDE

H!

My IDE is tells me, that it can't resolve directory.

I resolved some hints with adding the correct SOURCE ROOT. But there is something special I was not able to resolve.

My directory - structure is:

ROOT/
-assets/
-modules/
    -[Modulname]/
        -js/*.js
        -css/*.css
        -view/*.html
    -[Modulname]/
        -js/*.js
        -css/*.css
        -view/*.html
-[other dirs...]

In the HTML files the paths are different than they are located in project.

<script src="js/modulname/example.js"></script>

This file is located in the project-root:

ROOT/modules/modulname/js/example.js

Is there a way to tell PHPStorm this kind of path-switch?

If yes best would be a pattern so i dont have to add it for every module. Something like:

/js/{{modulename}}/{{file}} = ROOT/modules/{{modulname}}/js/{{file}}

Happy about tips and help

0
3 comments

You can create a jsconfig.json in you project root folder and specify your path aliases there:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "js/modulname1/*": ["./modules/modulname1/js/*"],
      "js/modulname2/*": ["./modules/modulname2/js/*"],
      ...
    }
  }
}
1

Thanks a lot. This helps.

Is there a way to simpify this with * pattern for foldername (modulename)? 

0

Please sign in to leave a comment.