TidySB
TidySB

Reputation: 35

Is there a way to minify CSS files at build time?

I'm dealing with an ASP.net project that's maintained by a couple of people via git.

We're looking to minify the CSS files at build time and have checked out the bundle and minify addon however this doesn't appear to offer an option for the minified code to be regenerated from the source files at each build.

Is there a better way for us to minify our source css files on each build?

Upvotes: 1

Views: 2457

Answers (3)

Yogesh
Yogesh

Reputation: 685

You can use Microsoft Ajax Minifier after build.

Explained here: https://www.codeproject.com/Articles/182690/Minify-Javascript-and-CSS-using-Microsoft-Ajax-Min

Or if you have integration with Jenkins then after build step you can call bat file and run minification on folder of your build directory.

For multiple technology projects, You can create exe based on Microsoft Ajax Minifier and after all builds are done, Run this exe using bat command from Jenking only to minify all the css and js files.

I have integrated this with PHP, ASP.Net and Silverlight code after build of these projects.

Upvotes: 1

Jan Franta
Jan Franta

Reputation: 1721

Understanding your question right, you want to concat and minify your css sources and time you build or deploy.
I do not now how your build stack look like, so I can guess only, but using css files I would use something like grunt or gulp.
On my self I prefer gulp. It is easy to create a task which concat, minify or also auto prefix your css files.
Once your task is created you can add it to your build script, task or bash.

This way works also fine with CI like wercker or travis.

Upvotes: 1

Ajay Kumar Oad
Ajay Kumar Oad

Reputation: 560

One better way is to make your file to online file (like CDN link github can help you in that) and next rather then adding all those css add that link which will be saving much of the build time.

  • Try to minify your file.

  • Try to make an online link file.

Upvotes: 0

Related Questions