Mantis Manager: An Asset Manager that minifies, combines, and publishes

9 followers

This wiki article has not been tagged with a corresponding Yii version yet.
Help us improve the wiki by updating the version information.

Hello everybody.

I've put together a system for asset management that publishes only changed files, minifies and combines CSS/JS, and publishes either locally or to S3.

I'll give you a quick overview here, but check out the github repo or the explanatory blog post to learn more.

The main part of the Mantis Manager is a little command line utility that invokes a component. The component will then loop through an assets directory of your choice and calculate a SHA for each file. If it's the first time you've run the script, it will publish all your assets. The next time you run it, it will calculate the SHAs and compare it to the previous SHAs and publish only the changed assets.

You can set up an array of JS & CSS files to be combined, and you can also turn on "minify" to compress the files. I've added the configuration below so you can see some of the options, but I have a full technical explanation on the github repo and a more high-level overview post.

'mantisManager'=>array(
    'class'=>'MantisManager',
    'runtimePath'=>'application.runtime',
    'assetsPath'=>'application.assets',
    'localManager'=>'localAssets',
    'remoteManager'=>'remoteAssets',
    'ignore'=>array(
        '*.psd'
    ),
    'css'=>array(
        'combine'=>array(
            'css/combined.css' => array(
                'css/base.css',
                'css/blue.css',
                'css/calendar.css',
                'js/bootstrap-select/bootstrap-select.css',
                'js/bootstrap-datepicker/datepicker.css',
                'css/styles.css',
            )
        ),
        'minify'=>true
    ),
    'js'=>array(
        'combine'=>array(
            'js/combined.js' => array(
                'js/bootstrap.js',
                'js/bootstrap-select/bootstrap-select.js',
                'js/bootstrap-datepicker/bootstrap-datepicker.js',
                'js/mantis.js'
            )
        ),
        'minify'=>true
    )
),

Total 1 comment

#13863 report it
aarondfrancis at 2013/07/03 02:19am
"Watch" command added

I just added a command to continuously run the ->publish command when you're running locally, so your assets will updated automatically. It suppresses all the console messages except errors and notifications of publishing files.

Leave a comment

Please to leave your comment.

Write new article