Bower global packages and references
Hello,
I am a bit lost with Bower and packages. I have installed Bower and set a global directory and installed a couple of libraries i use with almost all my projects (jquery, tinymce, …) with "--save -g" option. Then I have set a PHP include path that target my bower_components directory so i can see the libraries in my project window. So far so good, it seems, my libraries are all in one place and i can type "bower list" and it updates all of them at once. I am not sure i took the right path to do so but it seems ok.
But now i find myself having more work than before when i had one directory per library per project as when I have a new project i have to map all my bower_components libraries directories with the server deployment path to be able to upload the libraries to the server (and as i don’t want all the jquery (example) directories but just the jquery.js + jquery.min.js I need to be very specific). And now code completion doesn’t work anymore as my libraries are not referenced in the project root directory. I know this can’t be right…
As i see it one should be able to add a folder to a project structure and define it as a "shared external library" that would be kept up to date according to the GitHub version (example) and still be referenced when coding. Am I wrong ?
Thanks for your advices
Sam
Please sign in to leave a comment.
installing bower package globally can't be considered a good practice... Anyway, if you just like to get completion for JQuery, etc., you can add your bower packages as a JavaScript library (Preferences | Languages & Frameworks | JavaScript | Libraries). See https://blog.jetbrains.com/webstorm/2014/07/how-webstorm-works-completion-for-javascript-libraries/. Or, you can add this global shared folder as additional content root to your projects: Preferences | Directories, Add content root
Thanks for your answer Elena,
I just thought globally would make less trouble but locally is fine with me as well : would it change your advice if it was local ?
By local, do you mean local to project (i.e. located in the project dir)? You won't need any libraries/additional content roots then, all needed files will be in your project
I meant that : installing the packages through bower directly on the root of the project would help i assume. But i do not seem able to do this… As said in my first post i just wish to have all my project’s libraries up to date automatically : wether through bower or any other mean. My only point being that I have more than one library per project and do not wish to spend my time tracking which has changed.
>installing the packages through bower directly on the root of the project would help i assume
yes, likely