tuplejump / play-yeoman

Play + Yeoman integration sbt and play plugins
Apache License 2.0
238 stars 57 forks source link

The Play run hook runs 'watch' instead of 'serve' #82

Open anelson opened 8 years ago

anelson commented 8 years ago

My usual workflow with Play is to keep the SBT run task running during development, taking advantage of the automatic recompilation in Play. I'm trying to add a Javascript frontend build with the Yeoman/Grunt/Bower toolchain, which has worked great thanks to your plugin. However, there's an issue with the Play run hook that breaks my usual workflow. I'm too new to the use of this plugin to know if this is a bug or if more experienced developers use a different workflow, so allow me to describe the issue and you decide:

When I run a run command in SBT, the Play run hook in in sbt-yeoman runs based on this code:

override def afterStarted(addr: InetSocketAddress): Unit = {
  process = Some(runGrunt(base, gruntFile, "watch" :: Nil, isForceEnabled))
}

This runs grunt watch, but this doesn't run tasks like concurrent:server, which runs Compass and generates the CSS files in .tmp. Because of this, I have to manually run grunt concurrent:server first, before run. It seems to me that the Play run hook should run serve instead of watch, particularly since the instructions in the README for play-yeoman suggest commenting out the connect:livereload line in Gruntfile.js.

Shiti commented 8 years ago

The plugin executes grunt serve on run and then executes the grunt watch command. If you are using grunt-contrib-compass, there will be a task compass which can be called in the watch task. Can you share your Gruntfile.js ?

anelson commented 8 years ago

Sure, here is my Gruntfile.js: https://gist.github.com/anelson/7936871cff04c226e3fc

Shiti commented 8 years ago

In your watch task, the compass task is already added. But maybe the files are at a different path.

Can you please check if everything works correctly with the following steps?

$ cd projectName
$ cd ui
$ grunt serve

Make changes to a sass file and see if its reflected.

anelson commented 8 years ago

Running the following commands results in the .tmp/styles/main.css file being generated:

$ cd projectName/ui
$ grunt clean
$ grunt serve

however that is not my problem. My problem is the following:

$ cd projectName/ui
$ grunt clean

At this point, as you would expect, the .tmp/styles/main.css file is now deleted. Let's start the Play server:

$ cd ..
$ ./activator
$ run

in this case, .tmp/styles/main.css is still not created. The app loads, but without the stylesheet it renders improperly.

If I touch the app/styles/main.scss file, then the watcher picks that up and generates the .css file, but not before then.