Closed chris-martin closed 11 years ago
A simple solution, perhaps: If the minification option could be specified in the manifest file rather than by an SBT config key, then I could accomplish this easily enough by creating a second manifest.
That's interesting. How do you currently choose between versions of the file at runtime?
The idea of the current setup is to let you configure the build differently for development, beta and production, so you can switch on minification when you publish.
I originally wrote a plugin for the Lift web framework that used SBT Configurations to do this ( https://github.com/untyped/sbt-plugins/tree/master/sbt-runmode), but I'm not so sure that's the best route as it's fairly complex to set up.
Another approach is to use Java System properties (suggested by @seanparsons here: https://twitter.com/seanparsons/status/367185761680236544) which probably works better. Rough example:
val mode = System.getProperty("mode")
// ...
JsKeys.prettyPrint in (Compile, JsKeys.js) := (mode == "development")
Run SBT with one of the following the command lines:
sbt -Dmode=development
sbt -Dmode=production
Cheers,
Dave
On 13 August 2013 00:27, Christopher Martin notifications@github.comwrote:
A simple solution, perhaps: If the minification option could be specified in the manifest file rather than by an SBT config key, then I could accomplish this easily enough by creating a second manifest.
— Reply to this email directly or view it on GitHubhttps://github.com/untyped/sbt-plugins/issues/36#issuecomment-22533511 .
I'd be tempted to suggest tweaking that code ever so slightly:
val mode = Option(System.getProperty("mode")).get
That forces a failure if the property isn't there, or use getOrElse(
How do you currently choose between versions of the file at runtime?
I don't. I'm writing a JavaScript library. It's for other people to use. Most libraries publish both a readable version and a minified version.
This issue has stalled. I'll close it for now.
As far as I can see, the options for minification are either to minify or to not minify. If I'm making a JS library, I don't want to decide this at compile-time; I want to produce both artifacts and let the user decide whether to use the minified version.
Is there currently a way to generate both?
And why not just generate both by default?