引言

我们在ASP.NET MVC 中经常会用到 bundleConfig.cs 文件来进行我们 css 和 js 的绑定, 那么在ASP.NET Core 中我们应该如何使用呢?

步骤一

在 Visual Studio 2015 工具->扩展和更新 中下载插件

然后重启 Visual Studio 2015

步骤二

在你的ASP.NET Core 项目的 Web 层中 的 project.json 文件中添加如下配置:

"tools": { "BundlerMinifier.Core": "2.0.238" }, "scripts": { "precompile": [ "dotnet bundle" ] }

步骤三

在 程序包管理器控制台 上输入 dotnet bundle 程序就会自动找到 bundleconfig.json文件 进行编译。

差不多就是这样的啦。

步骤四

如何配置 bundleconfig.json 文件 :

[ { "outputFileName": "output/bundle.css", "inputFiles": [ "css/lib/**/*.css", // globbing patterns are supported "css/input/site.css" ], "minify": { "enabled": true, "commentMode": "all" } }, { "outputFileName": "output/all.js", "inputFiles": [ "js/*.js", "!js/ignore.js" // start with a ! to exclude files ] }, { "outputFileName": "output/app.js", "inputFiles": [ "input/main.js", "input/core/*.js" // all .js files in input/core/ ] } ]

参考文献

http://dotnetthoughts.net/bundling-and-minification-in-aspnet-core/

https://github.com/madskristensen/BundlerMinifier/wiki

How to use Bundle&Minifier and bundleconfig.json in ASP.NET Core的更多相关文章

  1. 用"hosting.json"配置ASP.NET Core站点的Hosting环境

    通常我们在 Prgram.cs 中使用硬编码的方式配置 ASP.NET Core 站点的 Hosting 环境,最常用的就是 .UseUrls() . public class Program { p ...

  2. Talking appsettings.json in Asp.Net Core

    在ASP.NET Core中,默认提供了三个运行时环境变量,通过查看Hosting源代码我们可以看到,分别是Development.Staging.Production public static c ...

  3. asp.net core2.1 bundleconfig.json合并压缩资源文件

    在asp.net core中则可以使用BuildBundlerMinifier来进行css,js的压缩合并 1.使用NuGet安装 BuildBundlerMinifier(也可以在vs中下载安装扩展 ...

  4. 一、.net Core bundleconfig.json

    一.bundleconfig.json [ { "outputFileName": "wwwroot/css/site.min.css", "inpu ...

  5. 终于等到你!WebOptimizer - A bundler and minifier for ASP.NET Core

    迷人的 ASP.NET Core 有一个美中不足之处,自从一开始接触它到现在,我就一直不喜欢,一直想找到替代品,甚至想过自己实现一个,它就是 BundlerMinifier . 昨天面对 bundle ...

  6. ASP.NET Core 在 JSON 文件中配置依赖注入

    前言 在上一篇文章中写了如何在MVC中配置全局路由前缀,今天给大家介绍一下如何在在 json 文件中配置依赖注入. 在以前的 ASP.NET 4+ (MVC,Web Api,Owin,SingalR等 ...

  7. ASP.NET Core中的project.json何去何从?

    Shawn Wildermuth (https://wildermuth.com/2016/05/12/The-Future-of-project-json-in-ASP-NET-Core) If y ...

  8. 【无私分享:ASP.NET CORE 项目实战(第六章)】读取配置文件(一) appsettings.json

    目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 在我们之前的Asp.net mvc 开发中,一提到配置文件,我们不由的想到 web.config 和 app.config,在 ...

  9. [asp.net core]project.json(1)

    摘要 前面介绍了使用vs2015新建asp.net core web的内容,这篇文章学习下project.json文件的内容. project.json 原文:https://docs.microso ...

随机推荐

  1. [LeetCode] Longest Substring with At Most K Distinct Characters 最多有K个不同字符的最长子串

    Given a string, find the length of the longest substring T that contains at most k distinct characte ...

  2. [LeetCode] Happy Number 快乐数

    Write an algorithm to determine if a number is "happy". A happy number is a number defined ...

  3. [LeetCode] Spiral Matrix 螺旋矩阵

    Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...

  4. [LeetCode] 3Sum 三数之和

    Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...

  5. 使用C#把发表的时间改为几年前,几个月,几天前,几小时前,几分钟前,或几秒前

    我们在评论中往往会看到多少天前,多少小时前. 实现原理:现在时间-过去时间 得到的时间差来做比较 下面我定义了一个Helper类,大家直接引用即可,参数就是时间差,注意时间差类型是TimeSpan类型 ...

  6. 应如何取B/S的B端的IP

    我们常讨论说要取真实IP,不同场景所谓的真实IP含义不一样. 如你要根据客户端IP去判断客户所在区域,那么要记录客户的出口IP,这里的出口IP才是你所谓的真实IP. 如你要判断多个客户端是不是同一个, ...

  7. php 设计模式--准备篇

    要了解设计模式 首先我们要先了解 php的命名空间和类的自动载入的功能 下面我们来说一下 命名空间 概念缘由:比如一个a.php的文章 但是我们需要两个 此时同一个目录下不可能存在两个a.php 那么 ...

  8. 我们常用,却容易忽视——CSS的BFC(Block formatting contexts)

    BFC——一个我们容易忽视掉的布局神器 今天给大家说说BFC这个概念,在说概念前,先给大家看个例子: 首先,定义三个div块元素   效果: 我们发现,块级元素的排列顺序是从上往下,一块接着一块,在w ...

  9. JS常用正则表达式

    1.IP地址验证 var reg = /^(([1-9])|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))\.(([0-9])|([1-9][0 ...

  10. Python的多线程(threading)与多进程(multiprocessing )

    进程:程序的一次执行(程序载入内存,系统分配资源运行).每个进程有自己的内存空间,数据栈等,进程之间可以进行通讯,但是不能共享信息. 线程:所有的线程运行在同一个进程中,共享相同的运行环境.每个独立的 ...