a transform for loading YAML files in requirejs, using js-yaml
$ bower install require-yaml --saveIf you prefer a manual install, make sure to satisfy the js-yaml and text dependencies.
First, make sure the module names js-yaml and text resolve to the proper locations (both are installed alongside the loader when you are using bower):
requirejs.config({
paths : {
'yaml' : './bower_components/require-yaml/yaml',
'js-yaml' : './bower_components/js-yaml/dist/js-yaml',
'text' : './bower_components/requirejs-text/text'
}
});Now you're ready to require YAML as plain JavaScript objects:
require('yaml!some/folder/somefile.yaml', function(data){
console.log(data); // => logs the transformed object
});For more information see the js-yaml repository.
On build time you can simply use stubModules in your build config to get rid of the parser in the file you ship to production:
({
stubModules: ['text','js-yaml','yaml']
})##License MIT © Frederik Ring