5

I need some help with organizing js files in VS.

So my problem is, that VS(MVC) put all js files by default into the script directory, but i also have js created by me, in a sub directory, like this:
enter image description here

Now my problem is that when i open the scripts folder, the js files installed by NuGet take 2-3 screens in length, so i either have to open/close it every time, or scroll trought like there is no tomorrow.

So my question is, is there any good solutions to it? Like moving all the files into a subdirectory, and change every bundles, and NuGet config, or should i create a separate script directory for my custom js files? Any good ideas?

MrKekson
  • 720
  • 6
  • 18

2 Answers2

1

Sadly you cannot change the default folder that NuGet downloads the files. Is the author of the NuGet package that decides where it will get installed.

An alternative is to use Bower. With it you can control where files get downloaded (look at this question).

Or, as you said, move your own javascripts to another folder and forget about the default.

Community
  • 1
  • 1
fabriciorissetto
  • 9,475
  • 5
  • 65
  • 73
1

You can place and use as many subdirectories you wish for your own scripts.

With the help of Bundle.IncludeDirectory all your scripts will be added to the bundle without having to define multiple bundles.

Concerning nuget I don't think you can (re)place those scripts at a location of your choice.

See Stackoverflow: Include all files in a folder in a single bundle

Community
  • 1
  • 1
Tom B.
  • 2,892
  • 3
  • 13
  • 34
  • So with bundles.Add(new ScriptBundle("~/bundles/scripts") .IncludeDirectory("~/Scripts", "*.js", true)); I can define a directory beside scripts, like MyScripts, if i understand it correctly. But if i deploy it, will the iis find it in there, i had problems with css, after deployment. – MrKekson Jan 13 '16 at 14:18
  • Ok then, let me see, back in a fev min :P – MrKekson Jan 13 '16 at 14:20
  • bundles.Add(new ScriptBundle("~/bundles/angularapp") .IncludeDirectory("~/AngularScripts/", "*.js")); Working like a champ, on the dev machine, and the test deploy server too, no more endless scrolling for me! Thanks! – MrKekson Jan 13 '16 at 14:23