问题描述
asp.net核心文档显示了操作方法使用grunt或gulp捆绑和缩小 css
和 js
文件.但是,当我使用vs 2015创建项目时,它将 bundleconfig.json
文件添加到项目中.我想缩小wwwroot/js文件夹中的所有js文件.所以我更新了bundleconfig.json内部的现有行以使用通配符 *
Documentation for asp.net core shows how to do bundling and minification css
and js
files using grunt or gulp.However when i create a project using vs 2015 it adds bundleconfig.json
file into project. I want to minify all the js files inside wwwroot/js folder. So i updated the existing lines inside bundleconfig.json to use wildcard character *
{
"outputFileName": "wwwroot/js/*.min.js",
"inputFiles": [
"wwwroot/js/*.js"
],
// Optionally specify minification options
"minify": {
"enabled": true,
"renameLocals": true
},
// Optinally generate .map file
"sourceMap": false
}
但是,当我发布项目时却出现错误
however when i publish the project i get error
推荐答案
我认为您不能在 outputFileName
中使用通配符,因此请在此处使用绝对路径.要创建多个捆绑包,请在阵列中创建多个条目.
I think you can't have wildcards in outputFileName
, so use an absolute path here. To create multiple bundles create multiple entries in the array.
[
{
"outputFileName": "wwwroot/css/site.min.css",
// An array of relative input file paths. Globbing patterns supported
"inputFiles": [
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/js/site.min.js",
"inputFiles": [
"wwwroot/js/site.js"
],
// Optionally specify minification options
"minify": {
"enabled": true,
"renameLocals": true
},
// Optinally generate .map file
"sourceMap": false
}
]
以上内容来自默认的 bundleconfig.json
.
旁注:
*.min.js
也是 *.js
顺便说一句.因此,如果您不删除前一个捆绑包,它将在每个捆绑包中递归添加,因此请小心.
*.min.js
is also a *.js
btw. So if you don't delete the previous one it will be added recursively with each bundling, so be careful.
这篇关于如何缩小asp.net core中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!