IntelliJ IDEA
 
Get IntelliJ IDEA
You are viewing the documentation for an earlier version of IntelliJ IDEA.

Minifying CSS

Last modified: 10 August 2022

Required plugins:

CSS -  The plugin is available only in IntelliJ IDEA Ultimate, where it is enabled by default.

File Watchers -  Install the plugin on the Settings/Preferences | Plugins page, tab Marketplace. The plugin is available only in IntelliJ IDEA Ultimate.

Minification or compression means removing all unnecessary characters, such as spaces, new lines, comments, without changing the functionality of the source code. During development and debugging, these characters make code easier to read. At the production stage, they only increase the size of code to be transferred.

Most often compression is done as a step in your build process, with tools like webpack. If you're not using build tools, you can use stand-alone tools, such as CSSO or cssnano.

To minify your code automatically, you need to configure a CSSO File Watcher which will track changes to your files and run CSSO.

By default, minification starts as soon as a CSS file in the File Watcher's scope is changed and saved. You can specify other events that invoke CSSO. Learn more from File Watchers.

The generated minified code is stored in a separate file with the name of the source CSS file and the extension min.css. The location of this generated file is defined in the Output paths to refresh field of the New Watcher dialog. However, in the Project Tree, the file with the minified code is shown under the source CSS file which is displayed as a node. To change this default presentation, configure file nesting in the Project tool window.