Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
anelson opened this issue Sep 14, 2015 · 4 comments
Open

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

anelson opened this issue Sep 14, 2015 · 4 comments

Comments

@anelson
Copy link

anelson commented Sep 14, 2015

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
Copy link
Contributor

Shiti commented Sep 15, 2015

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
Copy link
Author

anelson commented Sep 15, 2015

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

@Shiti
Copy link
Contributor

Shiti commented Sep 15, 2015

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
Copy link
Author

anelson commented Sep 15, 2015

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.

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

No branches or pull requests

2 participants