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 ...
随机推荐
- webstorm对WebGL自动提示
默认竟然没有勾选上,怪不得提示的时候,有很多webgl接口找不到方法(虽然可以运行).
- C#调用天气查询服务
先引入天气查询服务 1.有点引用导入服务引用 //实例化 web引用名.WeatherWebService cn = new web引用名.WeatherWebService() ...
- 我的操作系统复习——I/O控制和系统调用
上篇博客介绍了存储器管理的相关知识——我的操作系统复习——存储器管理,本篇讲设备管理中的I/O控制方式和操作系统中的系统调用. 一.I/O控制方式 I/O就是输入输出,I/O设备指的是输入输出设备和存 ...
- Java简易日历的实现
import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; imp ...
- celery 框架
转自:http://www.cnblogs.com/forward-wang/p/5970806.html 生产者消费者模式 在实际的软件开发过程中,经常会碰到如下场景:某个模块负责产生数据,这些数据 ...
- iOS开发--OC调用JS篇
OC调用JS篇 其中相对应的html部分如下: <html> <header> <meta http-equiv="Content-Type" con ...
- 【转】iOS动态库和静态库的简要介绍
静态库与动态库的区别 首先来看什么是库,库(Library)说白了就是一段编译好的二进制代码,加上头文件就可以供别人使用. 什么时候我们会用到库呢?一种情况是某些代码需要给别人使用,但是我们不希望别人 ...
- poj3417 LCA + 树形dp
Network Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4478 Accepted: 1292 Descripti ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 很不错的Intent用法 适用于正在开发的伙伴。自己看到了,也分享给大家吧。
本文介绍Android中Intent的各种常见作用. 1 Intent.ACTION_MAIN String: android.intent.action.MAIN 标识Activity为一个程序的开 ...