如何在apache服务器中部署ember-cli项目 [英] how to deploy ember-cli project in apache server
问题描述
我有以下问题。
我用ember-cli创建了一个ember应用程序。
I created an ember application with ember-cli.
应用程序通过url http:// localhost:4200 /
运行命令 ember serve
The application works fine on nodejs through the url http://localhost:4200/
when running the command ember serve
我想在apache httpd服务器上部署此应用程序。
I want to deploy this application on an apache httpd server.
为了这样工作,我认为它在firefox中打开时应该也可以独立工作。
In order that this will work i think that it should work also standalone when opening in firefox.
当我在firefox中打开它时,我会收到一个错误:
When i open it in firefox i get an error:
要求未定义
require is not defined
生成的index.html
The generated index.html is
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Foo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">
<base href="/" />
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/foo.css">
</head>
<body>
<script>
window.FooENV = {"environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"LOG_RESOLVER":true,"LOG_ACTIVE_GENERATION":true,"LOG_MODULE_RESOLVER":true,"LOG_VIEW_LOOKUPS":true},"LOG_MODULE_RESOLVER":true};
window.EmberENV = window.FooENV.EmberENV;
</script>
<script src="assets/vendor.js"></script>
<script src="assets/foo.js"></script>
<script>
window.Foo = require('foo/app')['default'].create(FooENV.APP);
</script>
</body>
</html>
我如何解决这个问题?
谢谢,
David
推荐答案
file:///J:/assets/ndd.css
这看起来像我您只需双击dist文件夹中的index.html文件即可。这不起作用!
This looks to me like you just double clicked your index.html file in your dist folder. This does not work!
您必须通过http服务器为您的目录提供服务。
You have to serve your directory by an http-server.
使用npm安装一个简单的http服务器:
Install a simple http server with npm:
npm install -g http-server
移动到您的dist文件夹并运行 http-server
。您将看到以下消息:
Move to your dist folder and run http-server
. You will see a message like this:
Starting up http-server, serving ./ on port: 8080
现在,您可以在Firefox中查看您的Ember应用程序: http:// localhost:8080
Now you can check your ember app in Firefox on: http://localhost:8080
这篇关于如何在apache服务器中部署ember-cli项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!