如何在 github 页面上部署使用 ember-cli 开发的 Ember.js 应用程序? [英] How do I deploy Ember.js app developed with ember-cli on github pages?
问题描述
我已经使用 ember-cli 成功创建了一个小应用程序.我尝试将它推送到我的 github 存储库的 gh-pages 分支,但它在浏览器控制台中显示错误
I have successfully created a small application using ember-cli. I tried pushing it to gh-pages branch of my github repo but it shows error in browser console
Uncaught ReferenceError: require is not defined
从 dist/assets
加载 vendor.js 和 vendor.js 文件也失败.
loading of vendor.js and vendor.js files from dist/assets
is also failing.
我也无法从本地机器的 dist
文件夹中运行独立的 ember 应用程序,同样的错误.
I'm not able to run standalone ember app from dist
folder in local machine as well, same errors.
有人试过吗?如果是,如何正确操作?
has anyone tried it. if yes how to do it correctly?
推荐答案
自 2014 年 12 月起,还有一个 为此添加了 ember-cli 插件.
Since December 2014 there is also an ember-cli addon for this.
首先确保将 config/environment.js
中的 modulePrefix
设置为您在 github 上的存储库名称.例如,对于 https://github.com/username/my-cool-repo应该是 modulePrefix: 'my-cool-repo'
.
First make sure to have set modulePrefix
in config/environment.js
to your repo's name on github. E.g., for https://github.com/username/my-cool-repo it should be modulePrefix: 'my-cool-repo'
.
然后按照以下说明操作:
Then follow these instructions:
安装插件.
$ ember install:addon ember-cli-github-pages
提交插件所做的更改.
<代码>$ git add .&&git commit -m "已安装插件 ember-cli-github-pages"
仅使用必要的文件创建 gh-pages
分支.$ git checkout --orphan gh-pages &&rm -rf `ls -a |grep -vE '.gitignore|.git|node_modules|bower_components|./|../'` &&git 添加.&&git commit -m "初始 gh-pages 提交"
Create the gh-pages
branch with only the necessary files.
$ 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"
切换回源分支(很可能是 master
).$ git checkout master
Switch back to your source branch (most likely master
).
$ git checkout master
将您的 ember 应用构建到 gh-pages
分支.$ ember gh-pages:commit --message "初始 gh-pages 发布"
Build your ember app to the gh-pages
branch.
$ ember gh-pages:commit --message "Initial gh-pages release"
将所有内容(或至少是 gh-pages
分支)推送到 github.
Push everything (or at least the gh-pages
branch) to github.
(这与 ember-cli <= 0.1.4 不同,将来可能会再次更改.请务必访问 插件的自述文件.)
这篇关于如何在 github 页面上部署使用 ember-cli 开发的 Ember.js 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!