untyped / sbt-plugins

SBT plugins for Javascript, Coffeescript, LESS, SASS, and Mustache compilation
73 stars 23 forks source link

Don't know how to serve sbt-js files #69

Closed countingtoten closed 9 years ago

countingtoten commented 9 years ago

I'm running into the same problem as this stack overflow user http://stackoverflow.com/questions/27251121/how-to-serve-files-generated-by-sbt-js-using-spray-can

I have a problem that after using sbt-js to compile my JavaScript files, the compiled files are in resource_managed directory but the uncompiled files are still in the resource directory. When the app runs it will use the uncompiled files in the resource directory.

If I move the JavaScript files to a /src/main/js directory, the uncompiled files won't be included in the .jar package, but now I don't know how to access them. I'm using spray and creating custom routes for the JavaScript, but I'm loading and keeping the JavaScript in memory. ex: scala.io.Source.fromURL(getClass.getResource("/js/app.js")) Is there a better way to access the compiled js, preferably using one of the spray file and resource directives?

Thanks, Jim

davegurnell commented 9 years ago

Hi Jim,

It sounds like you should move your source files to a directory that isn't packaged with your application. Try something like:

sourceDirectory in (Compile, JsKeys.js) := baseDirectory.value / "src" / "main" / "js"

Move your source files to the relevant directory.

I'm not thoroughly sure on the syntax or the directory structure without trying it, but the intention is your target files get packaged by Spray but src/main/js doesn't.

Hope this helps,

Dave

On 18 Feb 2015, at 16:45, Jim notifications@github.com wrote:

I'm running into the same problem as this stack overflow user http://stackoverflow.com/questions/27251121/how-to-serve-files-generated-by-sbt-js-using-spray-can http://stackoverflow.com/questions/27251121/how-to-serve-files-generated-by-sbt-js-using-spray-can I have a problem that after using sbt-js to compile my JavaScript files, the compiled files are in resource_managed directory but the uncompiled files are still in the resource directory. When the app runs it will use the uncompiled files in the resource directory.

If I move the JavaScript files to a /src/main/js directory, the uncompiled files won't be included in the .jar package, but now I don't know how to access them. I'm using spray and creating custom routes for the JavaScript, but I'm loading and keeping the JavaScript in memory. ex: scala.io.Source.fromURL(getClass.getResource("/js/app.js")) Is there a better way to access the compiled js, preferably using one of the spray file and resource directives?

Thanks, Jim

— Reply to this email directly or view it on GitHub https://github.com/untyped/sbt-plugins/issues/69.

countingtoten commented 9 years ago

Got it, thanks. Changing the directory structure fixed it