1

I'm developing a relatively simple web app using play framework for the server and dart for the client. I'm using eclipse. Development and debug are fine on their own but how do to get them to work together?

Play has its own web server (activator) that knows how to load the entry points for each endpoint and the dart environment know how to serve up dart resources (pub serve) for dartium and (haven't tried this yet) serve js resources for other browsers. It there a way for activator to ask the dart/pub system for resources as needed?

I tried adding a symlink from the server static resource directly to to the dart/html resources but it seems these files need to be processed by pub server before they can be used by the browser.

2
  • I'm not sure what your added paragraph means exactly, but static ressources don't need to be processed by pub serve only Dart source files and HTML files containing Dart script tags and possibly CSS files which might be inlined. Can you provide more details about what you actually tried to accomplish? Commented May 18, 2015 at 8:25
  • In production, dart resources are compiled to static resources. But development the dart resources are not static. If I change something in the dart in the editor I want it reflected in the browser. Furthermore, I want to be able to debug the dart application in eclipse which I believe means running dart natively in dartium. Commented May 18, 2015 at 13:05

2 Answers 2

2

Günter's suggestion was pretty good. I installed nginx and used the following config

server {
    listen       8080;
    server_name  localhost;

    location / {
        # Dart pub serv
        proxy_pass http://localhost:9100;
    }

    location /api/ {
        # Play 
        proxy_pass http://localhost:9000/api/;
    }
}

I then start the dart server as

pub serve --port 9100

The typesafe/play server listens on 9000 by default.

I found I had to use a dart port number well away from the activator port because it seems to listen on nearby ports as well.

Evan

0

I guess the best way is to use a proxy with rules to forward requests for Dart resources to pub serve and play resources to activator. This would be simple to build in Dart for example using shelf, shelf_route and shelf_proxy or nginx with a few forwarding rules.

Not the answer you're looking for? Browse other questions tagged or ask your own question.