sbt / sbt-rjs

RequireJs optimizer plugin for sbt-web
Other
39 stars 28 forks source link

Source maps generated, although RjsKeys.generateSourceMaps=false is set #30

Open smessmer opened 10 years ago

smessmer commented 10 years ago

Using play 2.3.1.

My Build.scala looks like

val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings(
   scalaVersion := "2.10.4",
   version := appVersion,
   libraryDependencies ++= appDependencies,
   pipelineStages := Seq(rjs, digest, gzip),
   CoffeeScriptKeys.sourceMap := false,
   RjsKeys.generateSourceMaps := false,
   resolvers += "sbt-plugin-releases" at "http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/",
   resolvers += "sonaype-snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
   scalacOptions ++= Seq("-feature", "-deprecation"),
   testOptions += Tests.Argument("-oDF")
 )

The dependencies contain

"org.webjars" % "requirejs" % "2.1.14-1",

and the plugin.sbt contains

addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")

I created an empty main.js to make requireJs work, but I'm not using it. I'm accessing javascript files directly using their path/filename.

In dev mode, the sources are non-minified. Accessing path/file.js returns the non-minified output from the compiler.

Running the application in prod mode, it minifies the javascript sources correctly. Accessing path/file.js returns the minified javascript file. This is exactly what I want so far.

However, the browser also requests the source map path/file.js.src.js and the server delivers it.

Since I set CoffeeScriptKeys.sourceMap := false (see build file above), it doesn't deliver the coffee script file as source map anymore, but it still delivers the non-minified javascript file that is output by the coffeescript compiler. RjsKeys.generateSourceMaps := false doesn't seem to make a difference.

huntc commented 10 years ago

Thanks. Any chance of a sample project?

smessmer commented 10 years ago

I tried to reproduce it with a small sample project but failed unfortunately.

But I could track it down a bit further. There have been file.js.src.js files hanging around in the /target/web/rjs/build/javascripts directory. I deleted the whole /target folder and ran the project again. The file.js.src.js files were not recreated and my problem was solved - no source maps served by the server anymore.

Maybe they've been there from an earlier compiler run where source maps have been enabled and rjs doesn't clean them up when you disable source maps without clean compile?

huntc commented 10 years ago

Yeah, I suppose if rjs kicks in then we must ensure that its build directory is cleared out first. WDYT @pvlugter ?