简体   繁体   English

SailsJS到Phonegap?

[英]SailsJS to Phonegap?

I'm trying to create a Phonegap project from SailsJS project. 我正在尝试从SailsJS项目创建一个Phonegap项目。 As i found out so far, command "sails build" should generate www folder with files to import to Phonegap. 到目前为止,我发现,命令“ sails build”应生成带有文件的www文件夹,以导入到Phonegap。 I've tried that, but i get www folder without index file, views,.. It looks like custom grunfile is needed to get appropriate www folder content. 我已经尝试过了,但是我得到了没有索引文件,视图等的www文件夹。看起来需要自定义grunfile才能获取适当的www文件夹内容。 The problem is, i don't know how to build it. 问题是,我不知道如何构建它。 It would be great if somebody could provide that file... I'm sure it would be very helpful for many... 如果有人可以提供该文件,那将是非常不错的。我相信这对许多人都将非常有帮助。

Similar problem has been described here and got no answers so far. 此处已描述了类似的问题,但到目前为止没有任何答案。 How to make a phonegap mobile app from SailsJS 如何使用SailsJS制作phonegap移动应用

Thank you in advance! 先感谢您!

There does seem to be some confusion over what sails build and its v0.10.x equivalent, sails www , are intended for. 关于sails的sails build及其v0.10.x等效项(Sails sails www用途似乎确实有些混乱。

As Ben notes in his comment on your question, your backend Sails code, including models, controllers and the server-side views, need a Node JS server to run. 正如Ben在对问题的评论中指出的那样,您的后端Sails代码(包括模型,控制器和服务器端视图)需要运行Node JS服务器。 sails build only packages up your front-end assets --the stuff that usually ends up in .tmp/public --into a www folder that could, among other things, be dropped into a PhoneGap app. sails build仅将您的前端资产(通常以.tmp / public结尾的内容)打包到一个www文件夹中,该文件夹可以放到PhoneGap应用程序中。

The idea is that you could build your app locally without server-side views (using an assets/index.html file as your starting point instead), and communicate with the Sails back-end solely via AJAX or socket requests. 这个想法是,您可以在本地构建应用程序而无需服务器端视图(而是使用assets / index.html文件作为起点),并仅通过AJAX或套接字请求与Sails后端进行通信。 The front-end Javascript that communicates with the back-end server will ideally have a single configuration point, perhaps a line of code in index.html , that determines the location of the back-end server (for testing, it'd probably be http://localhost:1337 ). 理想情况下,与后端服务器进行通信的前端Javascript将具有单个配置点,可能是index.html中的一行代码,用于确定后端服务器的位置(对于测试而言,可能是http://localhost:1337 )。

Write and test all your code this way, and when you're ready to deploy to a Node-less environment (like PhoneGap), build your www directory (getting the benefits of minification that the Sails Grunt tasks provide), change that configuration to the location where you'll be deploying the Sails back-end (eg http://www.example.com:1234 ), and you're good to go. 以这种方式编写和测试所有代码,并准备将其部署到无节点环境(如PhoneGap)中时,构建您的www目录(获得Sails Grunt任务提供的简化优势),将该配置更改为您将在其中部署Sails后端的位置(例如http://www.example.com:1234 ),您可以使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM