Skip to content
This repository was archived by the owner on Feb 3, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class UglifyJsResourceMapper implements GrailsApplicationAware {

try {
Date start = new Date()
def output = new UglifyEngine().minify(original.text, [filename: original.name, noMunge: config?.noMunge ?: false])
def output = new UglifyEngine().minify(original.text, [filename: original.name] + config)
target.write(output)

resource.processedFile = target
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.grails.plugin.resource.minified.js.uglify

import groovy.json.JsonBuilder
import org.springframework.core.io.ClassPathResource
import org.mozilla.javascript.Context
import org.mozilla.javascript.Scriptable
Expand Down Expand Up @@ -66,8 +67,9 @@ class UglifyEngine {
compressedAst.mangle_names()
"""

def printOptions = new JsonBuilder(options?.beautifierOptions ?: [:]).toString()
uglifyCommand += """\
return compressedAst.print_to_string()
return compressedAst.print_to_string($printOptions)
}())
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@ class UglifyEngineTests extends GrailsUnitTestCase {
assert output.contains("Private")
assert !output.contains("comment")
}

void testBeautifier() {
def input = "var unicodeChar = '\u24b6';"
def output = uglifyEngine.minify(input, [filename: "In memory file"])
assert !output.contains("u24b6")

output = uglifyEngine.minify(input, [filename: "In memory file", beautifierOptions: [ascii_only: true]])
assert output.contains("u24b6")
}
}