In Visual Studio 2013, how do I minify Javascript and CSS in the post-build step

前端 未结 2 980
名媛妹妹
名媛妹妹 2021-02-06 02:49

In Visual Studio 2013, how do I minify Javascript and CSS in the post-build step? I\'d like to have every single css and js file compress into a .min.js, or .min.css in the sam

2条回答
  •  暖寄归人
    2021-02-06 03:20

    With Microsoft Ajax Minifier you could create powershell script to create minified versions of all files in given folder and add it to Post-build events.

    Example for js files(it will be similar for css):

    Get-ChildItem *.js -Exclude *.min.js |
        Foreach-Object{
        $file = [io.fileinfo]$_.Name
        ajaxmin $file.Name -out "$($file.Name).min$($file.Extension)"
    }
    

    Check also a page with full list of command line switches e.g.: -map creates source map file.

提交回复
热议问题