Laravel Elixir: How to minify files?

LuMa picture LuMa · May 14, 2015 · Viewed 11.2k times · Source

I want to use Laravel Elixir to minify my css/files files. But I don't want to use the mix-methode and merge them. All I want is to generate a "custom.min.js" file from my original "custom.js". Is there a way to do this with Elexir?

EDIT: To make it a bit clearer: My biggest issue is that I have two folders in "resources/assets": js and css. So I basically want to minify all files in there and have them minified in "public/js" and "public/css".

Answer

Kevin Woblick picture Kevin Woblick · Jul 30, 2015

Quote from the Laravel documentation:

Note: All tasks will assume a development environment, and will exclude minification. For production, use gulp --production.

This means if you want the files to be minified run gulp --production instead of just gulp. It's a better practise than enabling compression directly in the gulp file and makes sure you can debug your compiled files while developing the application.

If you want them to be placed in public/assets/css use the path as a second parameter:

mix.less('app.less', 'public/assets/css');