Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compress CSS & JS code with PHPStorm?

I'm using PHPStorm. This is very great software for web developers.

When I want to compress my CSS & JS files in PHPStorm , I can't find any option in PHPStorm.

So, Please tell me how to compress CSS & JS code in PHPStorm.

like image 939
Jooxa Avatar asked Dec 17 '12 09:12

Jooxa


2 Answers

Found Assets Compressor plugin. See if it helps.

EDIT - Changed to the new link as pointed by @spade

like image 149
web-nomad Avatar answered Sep 28 '22 17:09

web-nomad


PHPStorm supports minification by File Watchers. It supports integration with the YUI Compressor "out of the box", but it has some problems, e.g., with calc() function. My solution is to use minifier:

  1. Repeat the steps to install Node.js and npm from JetBrains manual
  2. Install minifier like YUI Compressor in manual (npm install minifier)
  3. Minifier documentation says: "Installing through npm will create a binary (minify) in the usual locations", but I have not found it (perhaps it is not created on Windows). Index.js file can be executed via node index.js command, but PHPStorm does not maintain this way ("Please set program to run!" error will be thrown). So I created .bat file with the following content:

.

echo off
node path\to\minifier\index.js %*
  1. Then in PHPStorm watcher settings in Program input field we set path to the .bat file. Note that Minifier uses a different method for setting the output path, so we have to change Arguments field: $FileName$ --output $FileNameWithoutExtension$.min.css
like image 32
Dmitry Avatar answered Sep 28 '22 16:09

Dmitry