Styles and Scripts Minification

Good practice is to minimize number of the HTTP requests by combining the CSS and JavaScript files. Also, these files can be minified to reduce their size by removing extra spaces, line breaks, replacing long variable names with the shorter ones etc. (The JavaScript files could be also obfuscated, which makes reverse engineering much harder.)

By default, Platformus uses the BundlerMinifier.Core package for that. To start using it add the corresponding reference to your *.csproj file:

  <DotNetCliToolReference Include="BundlerMinifier.Core" Version="3.2.449" />

Now, add the following lines to the same project file to run the bundling and minification process automatically on build:

<Target Name="PrecompileScript" BeforeTargets="BeforeBuild">
  <Exec Command="dotnet bundle" />

Finally, the BundlerMinifier.Core package needs the bundleconfig.json file to be present in the project’s root folder:

    "outputFileName": "wwwroot/areas/backend/css/output.min.css",
    "inputFiles": [
    "outputFileName": "wwwroot/areas/backend/js/output.min.js",
    "inputFiles": [
    "minify": {
      "enabled": true,
      "renameLocals": true
    "sourceMap": false

In this file you can specify which files and how exactly should be minified and combined. You can use the bundleconfig.json file from the Platformus.Core extension as a sample.