scala-js-chrome icon indicating copy to clipboard operation
scala-js-chrome copied to clipboard

Add support for content script and popup window

Open dantheman3333 opened this issue 8 years ago • 3 comments
trafficstars

Possible approach: because scala-js can only compile to one js file (along with a dependency js file), I think the content script and popup window should be different sbt projects - bringing the total to three.

The content script and popup projects can be normal scala-js projects and only require the ScalaJSPlugin.

In the scala-js-chrome project, the build.sbt will specify the the two other projects. The ChromeSbtPlugin will compile the content and popup projects and move their outputted js files to the correct build directory. The manifest.json will have to be modified as well.

I made a poc of creating three different projects and manually copying over the necessary files with an ugly shell script https://github.com/kramer425/scala-js-chrome-extension-example

dantheman3333 avatar Jun 25 '17 20:06 dantheman3333

I like the general idea of that. Do you think it would be possible instead of referencing the whole project to only reference a task that results in a file and have that potentially from another project? This would still leave the possibility of referencing the same project if someone wants to include everything in one.

lucidd avatar Jun 27 '17 08:06 lucidd

It would be great if it could be one project. Though, I have limited knowledge of sbt - are you suggesting that one task that calls chromeBuildOpt on a directory, and two that call fastOptJS/fullOptJS on other directories?

dantheman3333 avatar Jun 27 '17 23:06 dantheman3333

Currently we have something like val fullOptJsLib = TaskKey[Attributed[File]]("fullOptJsLib") which can be set to a task that produces a file. I think it may be possible to also set it to reference a task from another project to pull in that file during building. So i think we could provide additional settings for content scripts and such which the user can set to whatever task he wants including from different projects.

lucidd avatar Jun 28 '17 17:06 lucidd