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

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
	)
),
4 0
8 followers
Viewed: 7 363 times
Version: Unknown (update)
Category: Tutorials
Tags: assets, heroku
Written by: aarondfrancis
Last updated by: aarondfrancis
Created on: Jun 19, 2013
Last updated: 4 years ago
Update Article

Revisions

View all history

Related Articles