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
Processing wwwroot/js/*.min.js Illegal characters in path. Parameter name: path
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
}
]
This one above is from the default bundleconfig.json
.
On a side note:
*.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.