|Number of watchers on Github||196|
|Number of open issues||6|
|Average time to close an issue||3 months|
|Average time to merge a PR||11 days|
|Open pull requests||9+|
|Closed pull requests||0+|
|Last commit||over 2 years ago|
|Repo Created||over 6 years ago|
|Repo Last Updated||over 2 years ago|
|Organization / Author||lihaoyi|
|Do you use workbench? Leave a review!|
|View open issues (6)|
|View workbench activity|
|View on github|
|Fresh, new opensource launches 🚀🚀🚀|
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
A SBT plugin for scala-js projects to make development in the browser more pleasant.
localhost:12345, whenever you're in the SBT console. Navigate to localhost:12345 in the browser and it'll show a simple page tell you it's alive. You can access any file within your project directory by going to
localhost:12345/path/to/filein a browser.
Check out the example app for a plug-and-play example of workbench in action.
scala // for sbt 1.0+ addSbtPlugin("com.lihaoyi" % "workbench" % "0.4.0") // for sbt 0.13.x addSbtPlugin("com.lihaoyi" % "workbench" % "0.3.1")
Once the above installation steps are completed, simply open your desired HTML file via
http://localhost:12345 with the URL path being any file part relative to your project root. e.g.
localhost:12345/target/scala-2.12/classes/index.html. This should serve up the HTML file and connect it to workbench.
If you want to serve a defaultRootObject on
http://localhost:12345 and serve only files from a root directory you can set this via:
workbenchDefaultRootObject := Some(("build/index-dev.html", "build/")) // (defaultRootObject, rootDirectory)
If you're accessing Workbench remotely over a slow network, you can enable compression of the transferred data with:
workbenchCompression := true
Compression is only supported on sbt 1.0+
By default, the server starts up when sbt loads. Ie, starting the sbt terminal via
sbt will start the server as well.
This behaviour can be changed by adding on of the following settings to your
scala workbenchStartMode := WorkbenchStartModes.OnCompile
scala workbenchStartMode := WorkbenchStartModes.Manual
You have a choice of what you want to do when the code compiles.
This will to make any client browsers refresh every time
fastOptJS completes, saving you flipping back and forth between SBT and the browser to refresh the page after compilation is finished. This is the default behavior.
// WorkbenchPlugin must NOT be enabled at the same time enablePlugins(WorkbenchSplicePlugin)
This is an experimental feature that aims to perform an update to the code running in the browser without losing the state of the running code! Thus you can make changes to the code and have them immediately appear in the program, without having to restart and lose the current state of the application. See this video for a demo of it in action.
This live splicing is not doable in the general case, but only for some subset of changes:
lazy vals to classes/objects
This means that there are many changes that
spliceBrowsers does not support, such as.
vars to classes/objects
And many more. If the change is something that Workbench does not support, you'll see errors in the browser console:
And you'll need to refresh the page.
Note that you have to turn off the Scala.js inliner (as shown in the above SBT snippet) in order to have this work. The inliner performs inlinings across class and method boundaries that makes it hard to predict whether or not the live-splicer will work.
Lastly, note that
spliceBrowsers does not retroactively modify the state of the application as if the changes in the code had always been present. For example, values set by the constructor in instances of a class will remain as-is even if you modify the class constructor; only new instances will be affected by the modified constructor.
In general, it is entirely possible to get into weird/invalid states due to this live-splicing, and the general solution is simply to refresh the page.
With this done, you should be receiving the SBT logspam (compilation, warnings, errors) in your browse console, and the page should be automatically refreshing/updating when the application gets recompiled. If you have problems setting this up, try starting from the example app and working from there.
To develop, go into
example/ and run
sbt ~fastOptJS. Then you can go to
and see a small sierpinski-triangle application. Editing the code within
example/ should cause the SBT log-spam to appear in the browser console, and changes (e.g. changing the color of the background fill) should cause a recompile and updating of the browser animation.
To make changes to workbench, modify the workbench source code and stop/re-run
sbt ~fastOptJS. When workbench finishes re-compiling, SBT re-starts and the page becomes accessible, your changes to workbench will take effect.
Pull requests welcome!
updateBrowsersfeature, made obsolete by increased speed of
sbt reloadnow works
The MIT License (MIT)
Copyright (c) 2013 Li Haoyi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the
Software), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED
AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN