admin管理员组

文章数量:1278818

What is the officially blessed way to minify and bundle js/css in Visual Studio?

Up until last year, Bundler and Minifier was the Microsoft promoted way to go, but it's been abandoned and has some significant issues to boot.

So what is the currently supported way to bundle and minify JavaScript and CSS in Visual Studio 2019?

What is the officially blessed way to minify and bundle js/css in Visual Studio?

Up until last year, Bundler and Minifier was the Microsoft promoted way to go, but it's been abandoned and has some significant issues to boot.

So what is the currently supported way to bundle and minify JavaScript and CSS in Visual Studio 2019?

Share Improve this question asked Apr 29, 2020 at 21:05 AngryHackerAngryHacker 61.6k111 gold badges356 silver badges626 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

The Bundler and Minifier extension integrates with the CommandTaskRunner extension (which is still an active project) and can convert the bundleconfig.json files into Node/npm/Gulp tasks which do the same thing.

The bundle & minifier on the marketplace is abandonware. last update was in 2018.

Visual studio has now its own bundle & minifier called BuildBundlerMinifier and its last update was in 2020. it has more options like Grunt/Gulp, or converting to ES5 (with gulp-terser). It uses the same bundleconnfig.cfg json setup.

Files that can be minified are Js, Css and Html.

More info and how to install you can find it here.

Package manager Install-Package BuildBundlerMinifier -Version 3.2.449

Update February 2024: It's still an issue in Visual Studio (core-X) bundling and minifying js and css. There is no native support out of the box anymore. In the VS extensions manager, there is a Fork called bundler&minifier 2022+. It's better than the old one and uses a (somewhat) recent version of NUglify, but not so recent that it support latest CSS addons.

However, Grunt can also work but Grunt is a bit insecure by today's standards and now legacy.

You have other options in the like of (according to the usage statistics and GIT activity) Webpack, Parcel and Vite. Vite seems to be all the Hype now. Integration of those minifiers into VS is not as easy and for pure core project (not VUE or React based projects) it's a learning curve of their configs.

Another alternative for Visual Studio seems to be LigerShark Weboptimizer (nuGet package here). I would reend you try this first.

本文标签: How to bundle JavaScript and CSS in Visual StudioStack Overflow