Open tnbalu opened 10 years ago
1) Source map annotation prefix.
The generated minified source file is not containing the map file referance e.g. //@ sourceMappingURL=simple.js.map
Thanks!
Same issue here with version 1.12.0
It seem like closure compiler itself is not adding map file reference.
I see the same issue.. i digged down into the source and (without running it mind you) it looks like it uses the Google CompilerOptions object to configure this from JsMinifier.groovy:
If you can't wait for a fix to the plugin and just want to rewrite the sourcemap as a hack, you can do it in the doLast closure of the minifyJs task, something like: (my groovy-fu is rusty so feel free to make it better)
minifyJs {
source = combineJs
dest = file("${outputJsDir}/application.min.js")
sourceMap = file("${outputJsDir}/application.min.map")
closure {
warningLevel = 'QUIET'
}
doLast {
file("${outputJsDir}/application.min.js") << "\n//# sourceMappingURL=application.min.map"
Map srcMap = new JsonSlurper().parseText( sourceMap.text )
srcMap.sources = ["application.js"]
sourceMap.withWriter("UTF-8") { it << new JsonBuilder(srcMap).toPrettyString() }
}
}
tasks.minifyJs.dependsOn tasks.combineJs
Notes:
Thank you @djKianoosh that helped alot. For those that stumble upon this, fully qualify the class names:
Map srcMap = new groovy.json.JsonSlurper().parseText( sourceMap.text )
srcMap.sources = ["application.js"]
sourceMap.withWriter("UTF-8") { it << new groovy.json.JsonBuilder(srcMap).toPrettyString() }
@dparish ah yes, I assumed import groovy.json.*
at the top; same difference :)
Hi, I have created a minified file and sourcemap file.
In the sourcemap file sources path is absolute path "ie" d:/abcd/sdsd/sdsd/employee.js but it shoule be employee.js
Can you guide me how to change the path in sources.
Issue:- While it is running in test environment it will look for d://.../../employee.js