admin管理员组

文章数量:1180467

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.

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.

Share Improve this question asked Dec 17, 2012 at 9:54 JooxaJooxa 6373 gold badges12 silver badges27 bronze badges 2
  • 1 Usually build scripts should do so, not IDE – zerkms Commented Dec 17, 2012 at 9:55
  • 1 jetbrains.com/phpstorm/webhelp/minifying-javascript.html – Real Dreams Commented May 29, 2013 at 3:12
Add a comment  | 

3 Answers 3

Reset to default 21

Found Assets Compressor plugin. See if it helps.

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

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

See the related feature requests:

  • WEB-2138 Support automatic JavaScript and CSS minification
  • WEB-2125 Pre- and post-deployment commands

At the moment you can use third-party tools/plug-ins like suggested by @Pushpesh.

本文标签: javascriptCompress CSS amp JS code with PHPStormStack Overflow