Skip to content

Commit

Permalink
Use a newer uglify version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tin Pavlinic authored and mkurz committed Jan 11, 2024
1 parent c7747db commit cc64b8e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name := "sbt-uglify"
description := "sbt-web plugin for minifying JavaScript files"
addSbtJsEngine("1.2.2")
libraryDependencies ++= Seq(
"org.webjars.npm" % "uglify-js" % "2.8.14",
"org.webjars.npm" % "uglify-js" % "3.16.3",
"io.monix" %% "monix" % "2.3.3"
)

Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/com/typesafe/sbt/uglify/SbtUglify.scala
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,10 @@ object SbtUglify extends AutoPlugin {

val (outputMapFile, outputMapFileArgs) = if (grouping.outputMapFile.isDefined) {
val outputMapFile = buildDirValue / grouping.outputMapFile.get
IO.createDirectory(outputMapFile.getParentFile)
val directory = outputMapFile.getParentFile
IO.createDirectory(directory)
(Some(outputMapFile), Seq(
"--source-map", outputMapFile.getPath,
"--source-map-url", outputMapFile.getName,
"--prefix", "relative"))
"--source-map", s"base='${directory.getPath}',filename='${directory.toPath.relativize(outputFile.toPath)}',url='${outputMapFile.getName}'"))
} else {
(None, Nil)
}
Expand Down
9 changes: 7 additions & 2 deletions src/sbt-test/sbt-uglify/uglify-concat/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ val checkMapFileContents = taskKey[Unit]("check that map contents are correct")

checkMapFileContents := {
val contents = IO.read(file("target/web/stage/javascripts/concat.min.js.map"))
if (!contents.contains("""{"version":3,"sources":["a.js","b.js","x.js"],"names":["a","b","define","call","this"],"mappings":""") ||
!contents.contains(""","file":"concat.min.js"}""")) {
if (
!contents.contains(""""version":3""") ||
!contents.contains(""""sources":["a.js","b.js","x.js"]""") ||
!contents.contains(""""names":["a","b","define","call","this"]""") ||
!contents.contains(""""mappings":""") ||
!contents.contains(""""file":"concat.min.js"""")
) {
sys.error(s"Unexpected contents: $contents")
}
}
2 changes: 1 addition & 1 deletion src/sbt-test/sbt-uglify/uglify/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ val checkMapFileContents = taskKey[Unit]("check that map contents are correct")

checkMapFileContents := {
val contents = IO.read(file("target/web/stage/javascripts/a.min.js.map"))
val r = """\{"version":3,"sources":\["a.js"\],"names":\["a"\],"mappings":"AAAA,QAASA,KACR,MAAO","file":"a.min.js"\}""".r
val r = """\{"version":3,"file":"a.min.js","sources":\["a.js"\],"names":\["a"\],"mappings":"AAAA,SAASA,IACR,OAAO"\}""".r
if (r.findAllIn(contents).isEmpty) {
sys.error(s"Unexpected contents: $contents")
}
Expand Down

0 comments on commit cc64b8e

Please sign in to comment.