0

I tried to look for some info related to bundling, tried different scenario with the same result: doesn't work!

Here is the project structure:

..........
Content
    css
       style.css
    fonts
    images
.........
Scripts
    Plugin1
       src
          css
             style1.css  
          js
             js1.js                  
    Plugin2
       src
          css
             style2.css   
          js
             js2.js    
    Plugin3
       src
          css
             style1.css    
          js
             js2.js    

somejs.js
someotherjs.js

case 1 - works

bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/css/style.css"));

case 2 - doesn't work

bundles.Add(new StyleBundle("~/js/style").Include(
                  "~/Scripts/Plugin1/src/css/style1.css",
                  "~/Scripts/Plugin2/src/css/style2.css",
                  "~/Scripts/Plugin3/src/css/style3.css"));

My question is, how can I bundle my css from different folders in one single bundle? I know that if the styles are all in the same folder then will work.

Does this have to do anything with the path itself? Does the name of the bundle ... new StyleBundle("~/js/style").. must match the actual location of the css files (folder structure)?

When the page loads in the page source there is missing the bundle key for the one that doesn't work while for the other one is present:

<link href="/js/style?v=" rel="stylesheet"/>

<link href="/Content/css?v=z_NN8-Oubjqwg7jFATA50T7SzahDLay9Fi3Lti_eSJ81" rel="stylesheet"/>
David Dury
  • 5,537
  • 12
  • 56
  • 94
  • In what way do they not work? Are they not included in the output at all? Or are there issues with background images or other linked assets? – Anders Abel Jul 10 '14 at 06:15
  • The style is not included in the output, the page is all messed-up. When the page loads if I view the page source there is not mentioned the bundle key: while for the other one there is: – David Dury Jul 10 '14 at 06:21
  • You can't give a bundle the same name as a directory - http://stackoverflow.com/questions/15540528/bundling-scripts-are-not-getting-rendered/15555201#15555201 (I wouldn't think that Case 1 would work). You can create a single bundle by just specifying the paths... just like you did in Case 2: http://stackoverflow.com/questions/14563415/force-asp-net-mvc-bundle-to-render-the-javascript-files-in-a-certain-order/14563828#14563828 The actual name of the bundle can be anything really. Change it to some random word that isn't also a directory or file in your site. – MikeSmithDev Jul 11 '14 at 14:06
  • Also, perhaps your paths to images are getting messed up when the bundle directory is used instead of the source directory. Can test by using absolute path on the src for background images, etc. – MikeSmithDev Jul 11 '14 at 14:12
  • Also see https://stackoverflow.com/questions/14595405/404-errors-on-bundled-jquery-css-vs2012-publishing-to-azure/14595525#14595525 – MikeSmithDev Jul 11 '14 at 14:22

0 Answers0