Shared JavaScript files across multiple solutions

One of the systems I'm currently working on has a number of solutions, each with one MVC UI project (see below for an example layout). Most UI projects have a fair amount of JavaScript and CSS. At the moment we are currently copying and merging any changes made to the common JS for each UI project (again, in different solutions), which is not ideal.

Here's a simplified view of some of the solutions:

Solution1
-- Solution1-UI
   -- Scripts directory (includes both shared JS and JS specific to this UI project)
Solution2 solution
-- Solution2-UI
   -- Scripts directory (includes both shared JS and JS specific to this UI project)
Solution3 solution
-- Solution3-UI
   -- Scripts directory (includes both shared JS and JS specific to this UI project)
... other solutiuons with the same issue

      

What I would ideally like to do is create a generic solution or package (or whatever) that can contain generic JS and all affected solutions can reference them (Solution1, Solution2, etc.).

A quick search shows that this can be done if the projects are in the same solution (i.e. how do you share scripts from multiple projects in the same solution? ) But our use case is slightly different.

What are some of the accepted ways to achieve this?

+3


source to share


1 answer


In this case, you will need to have your own CDN, you will create a separate website that delivers your JS files, even though the URLs and other solutions just link to those URLs.

In your solutions, you will reference these scripts the same way you would reference the jquery CDN , but with their own URLs originating from which you created.



Another solution I can think of is to simply upload your script to a service like amazon s3 or google cloud and get a link to those files from there.

+1


source







All Articles