简体   繁体   中英

Asp.Net Core 2.1 Static Files

Normally we are link the css with like

<environment include="Development">
        <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
        <link rel="stylesheet" href="~/css/site.css" />
        <link rel="stylesheet" href="~/css/IndexCss.css" />
    </environment>

But can i just link the folder ? Cus have too many css need to link ... Or any suggustion

ASP.NET Core MVC comes with a built in bundler and minifier so that many CSS files can become one, also does the same for JavaScript files.

Just create a file called bundleconfig.json at the root of the project with content like this:

[
  {
    "outputFileName": "wwwroot/css/site.min.css",
    "inputFiles": [
      "~/lib/bootstrap/dist/css/bootstrap.css",
      "~/css/*.css"
    ]
  },
  {
    "outputFileName": "wwwroot/js/site.min.js",
    "inputFiles": [
      "~/js/*.js"
    ],
    "minify": {
      "enabled": true,
      "renameLocals": true
    },
    "sourceMap": false
  }
]

More info here: https://docs.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-2.2&tabs=visual-studio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM