What\'s the best practice for using the ASP.NET Core bundleconfig.json with development versus production environments? The prior bundler (BundleCollection) wou
I wouldn't exactly call this a best practice but the following works for me.
In the bundleconfig.json I prepare one bundle for development and one for production.
Bundle for development is just concatenated text, which is easy to read and debug.
Bundle for production is minified and may optionally include source map.
{
"outputFileName": "wwwroot/script.bundle.js",
"inputFiles": [
"wwwroot/node_modules/popper.js/dist/umd/popper.js",
"wwwroot/node_modules/jquery/dist/jquery.js",
"wwwroot/node_modules/bootstrap/dist/js/bootstrap.js"
],
"minify": {
"enabled": false,
"renameLocals": false
}
},
{
"outputFileName": "wwwroot/script.min.js",
"inputFiles": [
"wwwroot/script.bundle.js"
],
"minify": {
"enabled": true,
"renameLocals": true
},
// Optionally generate .map file
"sourceMap": false
}
The point is, that production bundle use only development bundle. That way I have to keep only one list.
On the page, where JS is needed, I add tags for two bundles.