YUI 3 Yogi: Configuring External Modules

Creating an external module directory for integration with YUI 3 has always been a bit of a pain. Although yogi has come around to help build the module directory, there had yet been a method to configure a module directory outside of the YUI source using the Y.Loader configurations. This pull request tries to resolve that issue.

How to Install from Source

Until the source has been merged into the main repository, the tool will need to be installed from my fork which is located here: https://github.com/bretkikehara/yogi. The master branch hold both changes for external module configuration creation and automatic directory resolving.

git clone https://github.com/bretkikehara/yogi.git yogi

npm install -g .

Setting up the Repository

Now that the customized yogi has been installed, the configuration file has to be setup. The default configurations assumes that the loader module has a config.js file.

yogi init loader

Setting up the js/config.js

Now withing the loader directory, please create a config.js file within the js folder. This JavaScript file will hold all the information pertaining to the configuration. An example of the file is:

YUI.applyConfig({
	groups: {
		extGroupName: {
 			modules: @MODULES@
 		}
 	}
});

Notice that in my extGroupName group that the modules have the @MODULES@ text. This text will be replaced with the module data as an object. Since the generated file will insert an object, the @MODULES@ cannot be wrapped with quotes as a String.

Setting up the Build.json

For the default yogi settings, the build.json file must be exactly like this.

{
	"name": "config",
	"builds": {
		"config": {
			"jsfiles": ["generated-config.js"]
		}
	},
	"shifter": {
		"jsstamp": false,
		"lint": false
	}
}

Setting up the meta/yui3.json

This file is not necessary! These files are for the yogi loader compilation.

How to compile

Now that the customized loader has been created, please run these commands within your external modules directory:


yogi loader --externalModules

Advertisements