How to make bundles unminify and list individual files when using a cookieless static content server?

前端 未结 2 1565
忘掉有多难
忘掉有多难 2020-12-21 07:28

I have two VS projects, one for the main website and one for a \"static content\" website where all the css, js, images, and other static content will be stored and accessed

2条回答
  •  醉酒成梦
    2020-12-21 07:42

    BundleTable.EnableOptimization = "false" isn't event coming in to play here, as your main site is referencing the "bundle", which is always going to be bundled and minified, regardless of debug status or EnableOptimization.

    So @Styles.Render("~/bundles/styles") on the static site will render the individual files when BundleTable.EnableOptimization = "false", but if you navigate directly to /bundles/styles, you still get the minified bundle (what you are doing from your main site).

    One option (perhaps your only) would be to configure the bundler on the static site to not minify the bundle when BundleTable.EnableOptimization = "false". This can be accomplished by writing a class that inherits from Bundle and uses it's own custom IBundleBuilder (you can even write the file name as a comment as you add each file into the bundle). Some example code to point you in the right direction can be found on GitHub.

提交回复
热议问题