-
Notifications
You must be signed in to change notification settings - Fork 11
1.x tutorial build deploy
GitHubチュートリアルアプリケーションをビルド、デプロイする方法を紹介します。
Beezでは、設定ファイルにリリースするサーバーの設定を入れることで作業を終わらせる事ができます。
Beezは、この操作を簡単にするためにGrunt.jsを使用しています。
今回は、Mac 10.8に内蔵されている Apache(DocumentRoot) にリリースします。
Apache 確認
$ httpd -v
Server version: Apache/2.2.24 (Unix)
Server built: Jul 7 2013 18:05:17Apache 起動
$ sudo apachectl status
Password:Apache 動作確認
Access URL : http://localhost/local/index/local.release.html DocumentRoot : /Library/WebServer/Documents
conf/local/release.json
{
"release": { // enviroment name
"entrypoint": "index/index", // setting of "data-main"
"extend": { // Override Setting of requirejs
},
// Setting require.js
"requirejs": {
"baseUrl": "/local",
"paths": {
"underscore": "vendor/underscore",
"zepto" : "vendor/zepto",
"backbone" : "vendor/backbone",
"handlebars": "vendor/handlebars.runtime",
"beez" : "vendor/beez"
},
"shim": {
"backbone": {
"deps": ["underscore", "zepto"],
"exports": "Backbone"
},
"zepto": {
"exports": "$"
},
"underscore": {
"exports": "_"
},
"handlebars": {
"exports": "Handlebars"
}
},
"config": {
// configuration information used by beez
"beez.core": {
"url": {
//"app":"/", // application server url
"api":"https://api.github.com", // api server urlRoot (Backbone.Model#urlRoot)
"base":"/local", // require.js#data-main url
//"stat":"/local",// static file server url (css|image|...)
"vendor":"/local/vendor" // require.js or library url
},
"defines": { // beez in the definition.
"globals": { // set the global scope.
"DEBUG": false
}
},
"logging": {
"level": "DEBUG",
"separator": " "
},
// backbone#router
"router": {
"*default": {
"route": "*default",
"name": "index",
"require": "index/index",
"xpath": "/@/index"
},
"search": {
"route": "search",
"name": "searchIndex",
"require": "search/index",
"xpath": "/@/search"
}
}
}
}
}
}
}release.extend
リリース時は環境別に設定を変更しないため削除します。
release.requirejs.baseUrl
RequireJS の設定です。
今回は、URIが/localになります。
release.requirejs.paths
RequireJS の設定です。
今回は、URIが/local/vendor/*.jsになります。
release.requirejs.config["beez.core"].url
Beez、チュートリアルで使用するURLです。
Webサーバ、画像配信サーバーなどのURL設定です。
build.local.js
RequireJS Optimizer です。 JavaScript圧縮、モジュールの依存等々の設定を行います。
チュートリアルでは、すでにリリース用に設定してあります。
Optimize
optimizeを"uglify2"にすると、JavaScriptの圧縮も合わせて行うことが出来ます。
({
appDir: "./s",
baseUrl: "./",
dir: "./dist",
optimize: "none",
//optimize: "uglify2",
//optimizeCss: "standard", // use beez#beez-stylus2css
logLevel: 1,
waitSeconds: 7,
//http://lisperator.net/uglifyjs/codegen
//http://lisperator.net/uglifyjs/compress
uglify2: {
compress: {
global_defs: {
DEBUG: false
}
},
warnings: false
},
preserveLicenseComments: false,
paths: {
underscore: "../vendor/underscore",
zepto : "../vendor/zepto",
backbone : "../vendor/backbone",
handlebars: "../vendor/handlebars.runtime",
beez : "../vendor/beez"
},
modules: [
{
name: "index/index",
include: [],
exclude: [
'underscore',
'zepto',
'backbone',
'handlebars',
'beez'
]
},
{
name: "search/index",
include: [],
exclude: [
'underscore',
'zepto',
'backbone',
'handlebars',
'beez'
]
}
]
})Gruntコマンドを実行してビルドを行います。
$ grunt build
>> [environment] project name: tutorial
>> [environment] project directory: /Users/YOURNAME/Desktop/tutorial
>> [options] env: local
Running "jshint:src" (jshint) task
>> 12 files lint free.
Running "exec:beez_hbs2hbsc" (exec) task
s/index/hbs/footer.hbs
s/index/hbs/header.hbs
s/search/hbs/result.hbs
s/search/hbs/search.hbs
hbs/hbsp Compile
Base Directory: s
comile hbsc.js/hbsp.js file:
s/index/hbs/footer.hbsc.js
s/index/hbs/header.hbsc.js
s/index/local.develop.html
s/index/local.release.html
s/index/require.beez.local.develop.js
s/index/require.beez.local.release.js
s/search/hbs/result.hbsc.js
s/search/hbs/search.hbsc.js
finished.
Running "exec:beez_rjs" (exec) task
index/index.js
----------------
index/view/index.js
index/hbs/header.hbsc.js
index/view/header.js
index/view/content.js
index/hbs/footer.hbsc.js
index/view/footer.js
index/Model/index.js
index/index.js
search/index.js
----------------
search/i18n/en.js
search/i18n/ja.js
search/model/search.js
search/hbs/search.hbsc.js
search/view/search.js
search/hbs/result.hbsc.js
search/view/result.js
search/index.js
Running "exec:beez_csssprite" (exec) task
sprite build
Base Directory: s
finished.
Running "exec:beez_stylus2css" (exec) task
Stylus Compile
Base Directory: s
comiled css file:
s/index/styl/index.css
s/search/styl/index.css
copied css file:
---> Good luck to you :)
Done, without errors.releaseフォルダを作成し、そこにリリース物を配置します。
┗ $ grunt deploy
>> [environment] project name: tutorial
>> [environment] project directory: /Users/{{YOURNAME}}/Desktop/tutorial
>> [options] env: local
Running "mkdir:release" (mkdir) task
Creating "release/local"...OK
Running "exec:beez_deploy" (exec) task
Source Directory: dist
Output Directory: release/local
deploy regexp: /(dist/[^\/]*/index\.js|dist/index/require\.beez\.[^\/]*\.js|[^\/]*\.html|[^\/]*\.css|[^\/]*\.png|[^\/]*\.jpg|[^\/]*\.gif|[^\/]*\.ttf|[^\/]*\.eot|[^\/]*\.woff)$/
do not deploy regexp: /(_[^\/]*\.css|_[^\/]*\.png|_[^\/]*\.jpg|_[^\/]*\.gif|_[^\/]*\.ttf|_[^\/]*\.eot|_[^\/]*\.woff)$/
extend regexp: unused
deploy: release/local/index/index.js
deploy: release/local/index/local.develop.html
deploy: release/local/index/local.release.html
deploy: release/local/index/require.beez.local.develop.js
deploy: release/local/index/require.beez.local.release.js
deploy: release/local/search/index.js
finished.
Running "exec:beez_ignore" (exec) task
Base Directory: release/local
remove regexp: /(:)/
do not remove regexp: /(:)/
extend regexp: unused
finished.
Running "copy:vendor" (copy) task
Created 1 directories, copied 14 files
Done, without errors.先ほどのApacheのDocumentRootに release/local ディレクトリごとコピーします。
$ sudo cp -rf ./release/local /Library/WebServer/Documents/以上でリリース作業は終了です、お疲れさまでした。
リリースしたものが、ちゃんと見れるかどうかブラウザにアクセスしてください。
http://localhost/local/index/local.release.html
$ sudo apachectl status上記のデプロイまでを全て実行するには以下のコマンドを打ってください。
$ grunt