YUI Compressor Extension
DESCRIPTION:
YUI Compressor Extension is an enhancing library of YUI Compressor . The following functions can be used by this extension.
-
CLI interface
-
Compression and uniting of multiple assets
REQUIREMENTS:
-
yui-compressor
-
cri
-
win32-open3 (Only win32-Platform)
INSTALL:
$ gem install yui-compressor-ext
Usage
First Step
Please see here about Ruby-YUI Compressor.
Basic Concepts
For example, it is assumed that the following files exist.
/path/to/assets/javascripts/hoge.js
/path/to/assets/javascripts/foo.js
/path/to/assets/css/base.css
/path/to/assets/css/custom.css
Create configuration file to /path/to/assets/config.yml
(YAML Format).
output_dir: /path/to/assets
js:
base_dir: /path/to/assets/javascripts
files:
- hoge.js #=> js:base_dir + hoge.js
- foo.js #=> js:base_dir + foo.js
output: min.js #=> output_dir + min.js
css:
# When do not use "base_dir"
files:
- /path/to/assets/css/base.css
- /path/to/assets/css/custom.css
output: min.css #=> output_dir + min.css
Compress and uniting CSS and JavaScripts (All).
$ cd /path/to/assets
$ yuicompress all
Then, JavaScript and the CSS file that the compression uniting is done based on the configuration file as follows are made.
/path/to/assets/javascripts/hoge.js
/path/to/assets/javascripts/foo.js
/path/to/assets/min.js <== created
/path/to/assets/css/base.css
/path/to/assets/css/custom.css
/path/to/assets/min.css <== created
To process only CSS or JavaScript, as follows is done.
$ yuicompress css (or js)
In addition, it is also possible to execute the place of the configuration file specifying it.
$ yuicompress css /path/to/assets/config.yml
Setting to options for YUI Compressor
Optional execution of YUI-Compressor can be described by the configuration file. Please see here and here about the option that can be set.
# Global options. It is applied to both of these.
options:
:charset: utf-8
:line_break: 100
output_dir: /path/to/assets
js:
# Options for JavaScript. It is merge to Global options.
options:
:charset: sjis
base_dir: /path/to/assets/javascripts
files:
- hoge.js
- foo.js
output: min.js
css:
# When do not use "base_dir"
files:
- /path/to/assets/css/base.css
- /path/to/assets/css/custom.css
output: min.css
LICENSE:
(The MIT License)
Copyright © 2010 Matsukei Co.,Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.