atom-minify

Minifies JS and CSS files, optionally on save.

armin-pfaeffle

111,413

131

0.8.0

MIT

GitHub

atom-minify

Minifies JS and CSS files, optionally on save; now supporting inline-parameters and minifier options.


Because minifier is no longer maintained, I created atom-minify which includes four CSS and three JS minifiers. Another feature is the flexible configuration which should give you full control over minification and created files. Inline-parameters complete the way of defining the output.

Requirements

When you want to use YUI Compressor or Google Closure Compiler, you must install Java. If Java is not present, you will see an error message.

Usage

Minify on save

Beside shortcuts and access via menu, which is described above, you can enable option Minify on save (shortcut: ctrl-alt-shift-m / ctrl-cmd-shift-m), so everytime you save a CSS or JavaScript file, it is minified to a new minified file. The filename can be configured by a filename pattern (by options 1 / 2 or by inline parameter).

Alternatively you can use minifyOnSave parameter to control this behaviour.

Usage by shortcut or menu

You can use two shortcuts to access the two different minification functionalites:

  1. ctrl-shift-m: Minify an existant and opened file to a new file (see options 1 / 2 or by inline parameter). If file already exists, content is overwritten.

  2. alt-shift-m / cmd-shift-m: Direct minification of content which means that visible CSS or JavaScript text is replaced by its minified version. So you can open a new tab, paste your code and minify it without saving any file.

Beside the shortcuts you also have the possibility to access these actions by menu:

4+3 minifiers

With this package you can select between four CSS and three JS minifiers. Especially when you don't want to install Java on your system, these feature is great for you. There even exists predefined shortcuts for instant changing the minifier.

Options & parameters

Beside the basic functionality, have a look at the options. You can configure a lot of things 😉

Since version 0.3 you have the possibility to use inline-parameters, defined as comment in the first line of you CSS or JS file. With these parameters you can overwrite the global options.

Options

Inline-parameters

Since version 0.3 you can define inline-parameters that overwrites the global options. These parameters applies only for current file. Here are the rules:

You can add them by writing a comment to the first line of your CSS or JS file. The parameters must be comma-separated. Values are optional If you need a comma as value, you have to put it into single or double quotation marks.

Examples for CSS files:

/* minifyOnSave, filenamePattern: test/$1.compressed.$2 */
OR
/* filenamePattern: "/this is just a test/project/css/$1.compressed.$2" */
body {
}
h1 {
}
/* minifierOptions: "line-break = 100" */
body {
}
h1 {
}

Example for JS files:

// minifier: yui-js, buffer: 8388608, minifierOptions: "charset = utf-8 nomunge"
function(document, window, undefined) {
    alert('Hello World!')
}(document, window);

Available parameters

Predefined shortcuts

Issues, questions & feedback

Please post issues on GitHub.

For other concerns like questions or feeback have a look at the discussion thread on atom.io.

Roadmap

Changelog

See CHANGELOG.md.