How to organize mixed HTTP server + web client Dart project files?

后端 未结 3 611
别那么骄傲
别那么骄傲 2020-12-30 07:19

I\'m planning to create a pure Dart application where both the HTTP server and the web client side is written in Dart. Coming from Java and Eclipse the ultimate would be tha

相关标签:
3条回答
  • 2020-12-30 07:42

    I would go for two separate projects.
    You won't need to make the client package a dependency on the server package.
    The server only needs to know where the directory with the build output of the client package is.
    Which files to serve is usually requested by the client. The client requests e.g. index.html and all further dependencies (.dart, .hmtl, .js, .img, .css, ...) are hard-coded in this file and therefore the server should not need to know any further details beforehand.

    0 讨论(0)
  • 2020-12-30 07:53

    This is work in progress:

    • prepare a Dart app for server-side deployment

    To improve the development experience you may use a symlink as a workaround so that you have the client files available in a directory of the server package.

    I suggest creating a feature request at http://www.dartbug.com/new for better support.

    0 讨论(0)
  • 2020-12-30 08:03

    I'd suggest organising two separate projects. There are a few things that you might profit from if you use this approach. The most obvious there's no coupling between client and server, you get a very clear separation. The other one is that your server can evolve independently of the client. Dart applications will need to be compiled to javascript. In the end you will have a dart server app serving javascript files (+ maybe dart files if you decide to do so). Some of the packages that you use on the server side are not available in dartium - you don't want to have to deal with this dependency mess. Your server might consist of more then just one app, maybe your server will have a module in java or some other language. Keeping this two project separately gives you a lot more flexibility.

    0 讨论(0)
提交回复
热议问题