Skip to content

1.x configuration env key

Kei Funagayama edited this page Mar 18, 2014 · 3 revisions

conf/[env]/[key].json

[key] とは

[key] の中に更に、圧縮版、非圧縮版、issue版といった、キー別に設定を分けて管理するための キー です。

[env]/[key].jsonは、develop.json, release.json, debug.json, といったふうに複数作る事で、キー別の差異を設定ファイルで分離します。

設定内容

{
    "develop": {
        "entrypoint": "index/index",
        "extend": {
            "condition": {
                "ua": ["android","ios"]
            },
            "content": {
                "config": {
                    "beez.core": {
                        "url": {
                            //"app":"http://192.168.2.1:1109/m/example",
                            "api":"http://192.168.2.1:1109/p",
                            "base":"http://192.168.2.1:1109/m/example/s",
                            //"stat":"http://192.168.2.1:1109/m/example/s",
                            "vendor":"http://192.168.2.1:1109/m/example/vendor"
                        }
                    }
                }
            }
        },
        "requirejs": {
            "baseUrl": "/m/example/s",
            "paths": {
                "underscore": "/m/example/vendor/underscore",
                "zepto"     : "/m/example/vendor/zepto",
                "backbone"  : "/m/example/vendor/backbone",
                "handlebars": "/m/example/vendor/handlebars.runtime",
                "beez"      : "/m/example/vendor/beez",
                "backbone.localStorage": "/m/example/vendor/backbone.localStorage"
            },
            "shim": {
                "backbone": {
                    "deps": ["underscore", "zepto"],
                    "exports": "Backbone"
                },
                "zepto": {
                    "exports": "$"
                },
                "underscore": {
                    "exports": "_"
                },
                "handlebars": {
                    "exports": "Handlebars"
                }
            },
            "config": {
                // configuration information used by beez
                "beez.core": {
                    "url": {
                        //"app":"http://0.0.0.0:1109/m/example",
                        "api":"http://0.0.0.0:1109/p",
                        "base":"http://0.0.0.0:1109/m/example/s",
                        //"stat":"http://0.0.0.0:1109/m/example/s",
                        "vendor":"http://0.0.0.0:1109/m/example/vendor"
                    },
                    "defines": {
                        "globals": {
                            "DEBUG": true
                        }
                    },
                    "logging": {
                        "level": "DEBUG",
                        "separator": " "
                    },
                    "router": {
                        "*default": {
                            "route": "*default",
                            "name": "todos",
                            "require": "todos/index",
                            "xpath": "/@/todos"
                        },
                        "todos/:state": {
                            "route": "todos(/:state)",
                            "name": "todos",
                            "require": "todos/index",
                            "xpath": "/@/todos"
                        }
                    }
                }
            }
        }
    }
}

概要

[env]/[key].json 設定ファイルは、大きく4つのセクションに分かれます。

  • entrypoint
  • extend
  • requirejs
  • requirejs.config["beez.core"]

entrypoint

requirejsで最初にロードされる script の path を指定します。

ベースディレクトリパスは設定の requirejs.baseUrl です。

require.beez.js.hbs を合わせて参照ください。

extend

アクセス端末 UserAgent 単位で都度 requirejs section を上書きする設定です。

Macのインターネット共有を使用した場合などに有効な設定です。

requirejs

起動時にこの設定がそのままrequirejs.config()に渡されます。

詳細は requirejsのドキュメント を参照

requirejs.config["beez.core"]

requirejs.config['beez.core']の内容が beez のプロジェクトに関する設定となっています。

このときキーがbeez.coreとなっているのはbeezの決め事です。

プログラム内で利用するコード

var config = beez.config;

設定説明

develop

このファイルの[key] と同じ文字を設定してください。

conf/local/develop.json であれば、developになります。

entrypoint

前述参照

extend

前述参照

condition.ua

UserAgentにマッチした場合に extend.content を requirejs に上書きします。

content

requirejs sectionで上書きしたいデータ

Mac OSX インターネット共有 環境のIPアドレス OSX 10.7: 10.0.2.1 OSX 10.8: 192.168.2.1

requirejs

前述参照

baseUrl, paths, shim

@see http://requirejs.org/docs/api.html#config

config

@see: http://requirejs.org/docs/api.html#config-moduleconfig

プログラムから module.config() で取得出来ます

config["beez.core"]

beez.config でconfig["beez.core"]のデータがプログラムから取得出来ます。

config.url

beez内部で利用しているURL情報をまとめています。 プログラム中でURLを設定ファイルに外出しする際はこちらに記述すると良いでしょう。

config.url.api

beez.Modelインスタンスで urlRoot の定義が明示的にされていない場合は、urlRootに自動でconfig.url.apiが設定されます。

beez.configから取得できますので、プログラム内で利用可能です 。

config.url.base

beez.Controller.css やbeez.manager.css のCSSロードのURL Prefixで使用されます。

beez.configから取得できますので、プログラム内で利用可能です。

config.url.vendor, config.url.app, config.url.stat

beezでは直接使用しません。

beez.configから取得できますので、プログラム内で利用可能です。 使用しない場合は消してしまって構いません。

logging

組み込み logcafe.js の設定

@see: https://github.com/CyberAgent/logcafe.js#configure

デバッグ、トレースログが多くなった場合は、excludes で、categoryを設定して出力しないようにできます。

"logging": {
    "level": "INFO",
    "separator": " "
    "excludes": ["beez"] // beezのログを出力しない
},

router

beez.Routerの設定

@see: Router

@see: Backbone.js#Router-extend

"router": {
    "*default": { // beez.Routerで一意な文字列
        "route": "*default", // ハッシュフラグメントのマッチ条件式
        "name": "todos", // routeにヒットした時に呼ばれるメソッド名 keyと同じにしておくのが望ましい
        "require": "todos/index", // メソッドが存在するcontrollerのファイルパス
        "xpath": "/@/todos" // beez.bmanager.controllerの管理Path
    }
},

manager

beez.managerの設定

css.interval

beez.manager.css がロード済みかcheckするインターバル(ms)。default) 1000 / 20

css.timeout

beez.manager.css がロードする時の timeout(ms)。 default) 1000 * 10

image.size

beez.manager.image がプールするHTMLImageElementの上限数

image.pool.crossOrigin

beez.manager.image が生成するHTMLImageElement の属性にデフォルトで設定するcrossOrigin

画像個別に設定することも可能です。

Clone this wiki locally