How to spread javascript and cshtml files into separate projects

348 views Asked by At

Currently I'm working on a big project which tends to have about 10000 javascript and cshtml files.

It's a good idea to have a shell project, and lots of business projects like:

MyCompany.Shell
MyCompany.BusinessDomain1
MyCompany.BusinessDomain2

in this way, MyCompany.Shell is a Web project, and the others are Class Libraries. How can I configure my Solution, TeamProject and MyCompany.Shell to use the JavaScript files which are spread over the Business projects.

FYI, I'm using HotTowel template and Durandal 2.0.1

1

There are 1 answers

2
Kenneth On

If you're using MVC to generate the views, there's not really a way to do that, because you'd have different web sites. Unless you deploy them into virtual directories, durandal can't get to the views. If you are deploying them into virtual directories then you just have to ensure that the paths to your views and viewmodels are correct at runtime.

Apart from that here are a few tips that maybe useful:

  • I think a single Durandal app with 10000 JS files is probably a bit over the top. In my opinion you'd be better of to partition you project into separate sub applications.
  • I wouldn't use MVC to render your views. I tried going that way once but it ends up in a mess. You'd be better of to keep your HTML static and do all the dynamic parts through a (JSON)API and a your viewmodels.
  • I wouldn't put my JS files together with my Business-projects (or domain logic FTM). What you want is a clean separation between what lives on the server and on the client. The separation should come from an API in the middle. That way you can evolve client and server side separately