Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Serve gulp files from dynamic URI #11

Open
miguelCT opened this issue May 9, 2016 · 1 comment
Open

Serve gulp files from dynamic URI #11

miguelCT opened this issue May 9, 2016 · 1 comment

Comments

@miguelCT
Copy link

miguelCT commented May 9, 2016

Hi,

I've been using the plugin for a few weeks and everything seem to work fine. However there's something that I'm missing in the plugin.

Context

I'm using gulp to call webpack in order to build the javascript bundle and index.html and generate the output files into the dist/ folder.
Also, I have configured the sbt-play-gulp plugin to always search for the static files into ui/dist.

That works as intender but my problem came when I wanted to use webpack-dev-server to make the webpack builds faster in developement. This webpack-dev-server starts another server and builds the webpack files in memory, without generating output files to dist/ folder.
Play! expects to have the gulp(webpack) output files in the dist/ folder but, as I've mentioned, the webpack-dev-server does not generates any files on disk, so Play can't serve any static files because there are no static built files in that folder in developement.

Regarding on a possible solution, I wonder if it could be possible to extend plugin logic to be able to resolve files not only from static directories (.tmp/serve, /dist, etc) but also from dynamic URI's, pointing to another server, for example.
It might be great if this configuration could be set in a similar way as follows:

gulp.devDirs=["ui/dist", "http://localhost:8080/dist"]

The idea would be, if a requested file is not found in the static directories, then fetch the requested file from the specified url.
Maybe that would fit in this point of the plugin: https://github.com/mmizutani/sbt-play-gulp/blob/master/play-gulp/app/com/github/mmizutani/playgulp/GulpAssets.scala#L91

This idea is similar than the explained in this post: http://stackoverflow.com/a/33386933, where it says to set the main server (Play) as a proxy to the webpack-dev-server:

You can use a hybrid approach, which essentially setup the webpack-dev-server as a proxy. You have your express server that serves everything except for assets. If it's an asset, the request gets forwarded/proxied to the webpack-dev-server. [...]

Having said that, do you think this would be an interesting improvement to the plugin? And if you do, do you think it could be done relatively easily or it may take some time to develope it?

PD: I'm not a scala or java developer so I'm not sure I could provide a PR in short time.

@almothafar
Copy link

Yeah its great idea, I'm making UI project but also serving mobile version like /mobile not only /ui, i'm doing dirty workaround for it is not really working good, I was think to suggest something like this but I thought it is out of scope for this plugin

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants