Search code examples
cssvisual-studio-code.net-coreasp.net-core-mvc-2.0

changes not being applied to minified file


I added this css

high {
    background-color: red;
}

medium {
    background-color: yellow;
}

low {
    background-color: whitesmoke;
}

to wwwroot\css\Site.css, and when I publish the application with dotnet publish, I can see the minified css file is being referenced but it does not contain these new styles.

bundleconfig.json

// Configure bundling and minification for the project.
// More info at https://go.microsoft.com/fwlink/?LinkId=808241
[
    {
      "outputFileName": "wwwroot/css/site.min.css",
      // An array of relative input file paths. Globbing patterns supported
      "inputFiles": [
        "wwwroot/css/site.css"
      ]
    },
  {
    "outputFileName": "wwwroot/js/site.min.js",
    "inputFiles": [
      "wwwroot/js/site.js"
    ],
    // Optionally specify minification options
    "minify": {
      "enabled": true,
      "renameLocals": true
    },
    // Optionally generate .map file
    "sourceMap": false
  }
]

Why is this happening? How can I ensure that this bundle config is being applied?


Solution

  • I found this link useful, where it mentioned the need to add the BuildBundlerMinifier package to the project.

    So after calling

    dotnet add package BuildBundlerMinifier
    dotnet restore
    

    I can see my css updates in the .min.css file