2014-06-25 33 views
10

我已經使用ember-cli成功創建了一個小應用程序。我試了一下推到我的github回購的GH-頁面分支,但它顯示了在瀏覽器控制檯錯誤vendor.js的如何在github頁面上部署使用ember-cli開發的Ember.js應用程序?

Uncaught ReferenceError: require is not defined 

裝載和vendor.js從dist/assets文件也是失敗的。

我無法在本地機器上運行dist文件夾中的獨立應用程序應用程序,同樣的錯誤。

有人試過。如果是,如何正確地做到這一點?

+0

什麼ü在控制檯中?可能是基礎網址的問題。 http://iamstef.net/ember-cli/#deployments – blessenm

+0

自己測試[費用應用](http://kushdilip.github.io/Bounty-Web-Expenses/dist/) – kushdilip

+0

我認爲你需要推動'dist'文件夾中的內容到gh頁面分支(在其引擎蓋下)。我不認爲你可以從'dist'服務。 – blessenm

回答

5

自2014年12月以來,還有一個ember-cli addon for this

首先確保已將modulePrefix設置爲config/environment.js到您在github上的回購商名稱。例如,對於https://github.com/username/my-cool-repo它應該是modulePrefix: 'my-cool-repo'

然後按照下列指示:

  1. 安裝插件。
    $ ember install:addon ember-cli-github-pages

  2. 提交插件所做的更改。
    $ git add . && git commit -m "Installed addon ember-cli-github-pages"

  3. 創建只有必要文件的gh-pages分支。
    $ git checkout --orphan gh-pages && rm -rf `ls -a | grep -vE '.gitignore|.git|node_modules|bower_components|\.\/|\.\.\/'` && git add . && git commit -m "Initial gh-pages commit"

  4. 切換回您的源代碼分支(最有可能的是master)。
    $ git checkout master

  5. 將您的燼寶應用程序構建到gh-pages分支。
    $ ember gh-pages:commit --message "Initial gh-pages release"

  6. 推一切(或至少gh-pages分支)到github上。

(這是爲灰燼,CLI < = 0.1.4不同,並可能在未來再次發生變化。請一定要參觀addon's readme

+0

我會試試這個。我最近開始使用ember-cli。 – kushdilip

+0

我測試了部分插件。但插件並沒有太大的作用。我仍然無法使用ember運行組織頁面..例如。說kushdilip.github.io。 即使這個回購頁面從https://yourUsername.github.io/myEmberApplication/dist – kushdilip

2

正如評論中已經說過的那樣:將中的baseUrl更改爲您要將應用推送到的GitHub存儲庫的名稱。例如:

你的GitHub程序存儲庫被稱爲myEmberApplication並駐留在

https://github.com/yourUsername/myEmberApplication.git

那麼URL這個項目的GH-頁面將

https://yourUsername.github.io/myEmberApplication

所以你的情況,你必須將baseUrl/(默認)更改爲/myEmberApplication

您必須這樣做的原因是因爲ember-cli將<base>標頭添加到您的index.html文件中。

相關問題