问题
I'm working on a scalajs project. My workflow is: make code changes, make project in IntelliJ, go to sbt and run fastOptJS task to produce js file, go to browser and test. I would like to remove the step of manually running fastOptJS task in sbt and make that happen automatically when I make project in IDEA. Is there any way to do that?
UPD: It would be also nice to keep sbt running between fastOptJS calls, cause it takes time for sbt to start.
回答1:
You can simply start the JavaScript compilation with the sbt
watch mode.
Select Run | Edit configurations...
and add a new SBT Task by pressing the green plus. In the field "Tasks:" define ~fastOptJS
and then run the new configuration.
It will compile again whenever you have changed something.
回答2:
This should be the workaround for your propose, instead of use "Make Project ( Ctrl + F9 )", you can create a run in IDEA and configure an external tool as the image shown, where you can run the fastOptJS task in sbt.
来源:https://stackoverflow.com/questions/39245849/how-to-run-sbt-task-on-make-project-in-intellij-idea