Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • bh 211 posts 720 karma points
    5 days ago
    bh
    0

    clientdependency not bundled/minified

    I'm using RequiresJs and RequiresCss and RenderJsHere and RenderCssHere, and the right files are getting added to my page. But, they're not being bundled or minified.

    master.cshtml:

    Html.RequiresCss("~/css/slick.css", 1)
        .RequiresCss("~/css/jquery.fancybox.css", 2)
        .RequiresCss("~/css/main.css", 3);
    
    Html.RequiresJs("~/scripts/slick.js", 1)
        .RequiresJs("~/scripts/jquery.fancybox.js", 2)
        .RequiresJs("~/scripts/main.js", 3);
    

    rendered as:

        <link href="/css/slick.css?cdv=1" type="text/css" rel="stylesheet"/><link href="/css/jquery.fancybox.css?cdv=1" type="text/css" rel="stylesheet"/><link href="/css/main.css?cdv=1" type="text/css" rel="stylesheet"/>
    
        <script src="/scripts/slick.js?cdv=1" type="text/javascript"></script><script src="/scripts/jquery.fancybox.js?cdv=1" type="text/javascript"></script><script src="/scripts/main.js?cdv=1" type="text/javascript">
    </script>
    

    ClientDependency.config

      <compositeFiles defaultProvider="defaultFileProcessingProvider" compositeFileHandlerPath="~/DependencyHandler.axd">
        <fileProcessingProviders>
          <add name="CompositeFileProcessor"
               type="ClientDependency.Core.CompositeFiles.Providers.CompositeFileProcessingProvider, ClientDependency.Core"
               enableCssMinify="true"
               enableJsMinify="true"
               persistFiles="true"
               compositeFilePath="~/App_Data/TEMP/ClientDependency"
               bundleDomains="localhost:123456"
               urlType="Base64QueryStrings"
               pathUrlFormat="{dependencyId}/{version}/{type}"/>
        </fileProcessingProviders>
    

    What am I missing?

  • Kevin Jump 1531 posts 9796 karma points MVP 3x c-trib
    5 days ago
    Kevin Jump
    100

    Hi,

    I think you are running the site in debug mode,

    check the compilation config in the web.config file

    <compilation defaultLanguage="c#" debug="true" batch="true" targetFramework="4.7.2" numRecompilesBeforeAppRestart="50" />
    

    While in debug mode, ClientDependency doesn't bundle the style or script files.

    If you set debug="false" then it should start to bundle the files.

    Kevin

  • bh 211 posts 720 karma points
    5 days ago
    bh
    0

    That's what it was. So, it's not possible to bundle/minify while debuging?

    How does clientdependency manage cachebusting, if I change one of my js or css files? I know I can manually change the version # in the cliendependency.config

    Thanks @KevinJump!

  • Kevin Jump 1531 posts 9796 karma points MVP 3x c-trib
    5 days ago
    Kevin Jump
    1

    Hi,

    when bundling the cache file hash is a generated based of the file names (so for example all the stylesheets, and the version number in clientDependency.config).

    The quickest way to bust the cache is to change the client dependency version number (on v7 there is a health check for that), or change the name of one of your files. If you can its a good idea to set this up as a step in any deployment scripts you may have.

    I have in the past (on a site where it was hard to get to the configs) - had a version.01.css file - and just incremented the version (it doesn't matter if the file is there or not). as this will change the version number.

    For development, the best thing to do is have Chrome DevTools open and Disable Cache (while dev tools is open) checked.

Please Sign in or register to post replies

Write your reply to:

Draft