How to use Bundle&Minifier and bundleconfig.json in ASP.NET Core
引言
我们在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的更多相关文章
- 用"hosting.json"配置ASP.NET Core站点的Hosting环境
通常我们在 Prgram.cs 中使用硬编码的方式配置 ASP.NET Core 站点的 Hosting 环境,最常用的就是 .UseUrls() . public class Program { p ...
- Talking appsettings.json in Asp.Net Core
在ASP.NET Core中,默认提供了三个运行时环境变量,通过查看Hosting源代码我们可以看到,分别是Development.Staging.Production public static c ...
- asp.net core2.1 bundleconfig.json合并压缩资源文件
在asp.net core中则可以使用BuildBundlerMinifier来进行css,js的压缩合并 1.使用NuGet安装 BuildBundlerMinifier(也可以在vs中下载安装扩展 ...
- 一、.net Core bundleconfig.json
一.bundleconfig.json [ { "outputFileName": "wwwroot/css/site.min.css", "inpu ...
- 终于等到你!WebOptimizer - A bundler and minifier for ASP.NET Core
迷人的 ASP.NET Core 有一个美中不足之处,自从一开始接触它到现在,我就一直不喜欢,一直想找到替代品,甚至想过自己实现一个,它就是 BundlerMinifier . 昨天面对 bundle ...
- ASP.NET Core 在 JSON 文件中配置依赖注入
前言 在上一篇文章中写了如何在MVC中配置全局路由前缀,今天给大家介绍一下如何在在 json 文件中配置依赖注入. 在以前的 ASP.NET 4+ (MVC,Web Api,Owin,SingalR等 ...
- ASP.NET Core中的project.json何去何从?
Shawn Wildermuth (https://wildermuth.com/2016/05/12/The-Future-of-project-json-in-ASP-NET-Core) If y ...
- 【无私分享:ASP.NET CORE 项目实战(第六章)】读取配置文件(一) appsettings.json
目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 在我们之前的Asp.net mvc 开发中,一提到配置文件,我们不由的想到 web.config 和 app.config,在 ...
- [asp.net core]project.json(1)
摘要 前面介绍了使用vs2015新建asp.net core web的内容,这篇文章学习下project.json文件的内容. project.json 原文:https://docs.microso ...
随机推荐
- DeveloperExceptionPageMiddleware中间件如何呈现“开发者异常页面”
DeveloperExceptionPageMiddleware中间件如何呈现"开发者异常页面" 在<ASP.NET Core应用的错误处理[1]:三种呈现错误页面的方式&g ...
- docker学习(8) 在mac机上搭建私有仓库
docker的私有仓库类似maven的私服,一般用于公司内部搭建一个类似docker hub的环境,这样上传.下载镜像速度较快,本文将演示如何在mac上利用docker-machine搭建无需SSL证 ...
- [LeetCode] Minimum Height Trees 最小高度树
For a undirected graph with tree characteristics, we can choose any node as the root. The result gra ...
- Linux 中 SVN 重启关闭
a.启动SVN svnserve -d -r /A/B/svn/ 其中 -d 表示守护进程, -r 表示在后台执行 /A/B/svn/ 为svn的安装目录 b.关闭SVN 这里采取linux杀死进程的 ...
- 浅谈 Web 中前后端模板引擎的使用
前言 这篇文章本来不打算写的,实话说楼主对前端模板的认识还处在非常初级的阶段,但是为了整个 源码解读系列 的完整性,在深入 Underscore _.template 方法源码后,觉得还是有必要记下此 ...
- 研究Extension和Category的一个例子
Category: 1. 无法添加实例变量 2.将类的实现分散到多个不同文件或多个不同框架中. Extension: 1. 可以添加实例变量 注: 如果Category的头文件中也使用Extensio ...
- C++:通过gethostbyname函数,根据服务器的域名,获取服务器IP
本代码的编译环境为MAC,系统版本为10.11.6: #include <string.h> #include <netdb.h> #include <stdio.h&g ...
- jQuery实现二级菜单
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- Spring拦截机制之后端国际化心得
需求 前端请求的header里带有Prefer_Lang参数,向后端传递国际化信息,后端需要在处理业务之前(建立拦截机制),将Prefer_Lang保存于线程上下文. 思路分析 初次接收该需求时,为了 ...
- Zabbix监控mysql performance
介绍 zabbix监控mysql性能,使用zabbix自带的mysql监控模板,可以监控以下内容OPS(增删改查).mysql慢查询数量.mysql请求\响应流量带宽 配置 新建mysql监控用户 G ...