foreword
When publishing, some css and js files are long and multi-line, resulting in a little slow loading, so I want to compress the specified css or js
accomplish
Integrate yuicompressor-2.4.8.jar
Download address 1: https://github.com/yui/yuicompressor/releases
Download address 2: https://github.com/yui/yuicompressor/releases/download/v2.4.8/yuicompressor -2.4.8.jar
is downloaded and stored in a local path, which will be used later
Open IDEA
Open the Settings window (File->Settings in the upper left corner)
and operate Tools->External Tools as shown in the figure, click the plus sign to add the
previous name and Description customization
Program
java
Arguments
css use this
-jar F:\Development-Tools\yuicompressor-2.4.8.jar --type css --charset utf-8 $FilePath$ -o $FileNameWithoutExtension$.min.css
js use this
-jar F:\Development-Tools\yuicompressor-2.4.8.jar --type js --charset utf-8 $FilePath$ -o $FileNameWithoutExtension$.min.js
F:\Development-Tools\yuicompressor-2.4.8.jar This path is the local path of the jar you downloaded
In Working directory
, click the right + plus sign in the frame
and click OK, then restart IDEA.
After restarting, select the css or js file and right click, as follows
After generation,
double-click the min file to open it to see the effect. The generated min file has the same path as the original file.
Note: The original comments in the compressed min file will be cleared, so it is recommended to back up the original file