playframework 2.0 - Play Framework 2: JavaScript gets duplicated as a result of minification (google closure compiler) - Stack O

I have a weird issue related to JavaScript minification, the problem is that when placing JavaScript fi

I have a weird issue related to JavaScript minification, the problem is that when placing JavaScript files such as test1.js, test2.js inside /assets/javascript/test folder and using following options for closure piler:

val defaultOptions = new CompilerOptions()
    defaultOptions.closurePass = true
    defaultOptions.setProcessCommonJSModules(false)
    defaultOptions.setPrettyPrint(true)
    CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(defaultOptions)

They get minified, but this will cause both test1.min.js and test2.min.js files to share same codes as minified... this will cause some additional JavaScript bugs when files are used within same pages and takes up more disk space.

However, if CompilerOptions is not set, JavaScript piles properly without duplication but the pilation level is too strict and our JavaScript stops working because it says errors about some things written in those files. Overall, minification process is activated too late to fix all project js files to go through with default piler options so only option now is to configure it to work in a way which use light minification but without js duplication.. any help on this issue will be highly appreciated!

I'm using Play Framework 2.1.1 with Java project.

I have a weird issue related to JavaScript minification, the problem is that when placing JavaScript files such as test1.js, test2.js inside /assets/javascript/test folder and using following options for closure piler:

val defaultOptions = new CompilerOptions()
    defaultOptions.closurePass = true
    defaultOptions.setProcessCommonJSModules(false)
    defaultOptions.setPrettyPrint(true)
    CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(defaultOptions)

They get minified, but this will cause both test1.min.js and test2.min.js files to share same codes as minified... this will cause some additional JavaScript bugs when files are used within same pages and takes up more disk space.

However, if CompilerOptions is not set, JavaScript piles properly without duplication but the pilation level is too strict and our JavaScript stops working because it says errors about some things written in those files. Overall, minification process is activated too late to fix all project js files to go through with default piler options so only option now is to configure it to work in a way which use light minification but without js duplication.. any help on this issue will be highly appreciated!

I'm using Play Framework 2.1.1 with Java project.

Share Improve this question edited Apr 2, 2014 at 19:11 Charles 51.5k13 gold badges106 silver badges144 bronze badges asked Sep 6, 2013 at 12:28 Mauno VähäMauno Vähä 9,7883 gold badges35 silver badges55 bronze badges 3
  • 1 Did you ever find an answer to this? – shuttj Commented Jan 2, 2014 at 22:50
  • 1 After more digging, I found this issue for play 2.2.1: github./playframework/playframework/issues/2192 – shuttj Commented Jan 3, 2014 at 3:47
  • 1 Yea, I haven't had time to work it with lately, although we came up with some seriously big hack to workaround this issue, if 2.2.1 has it fixed it would be worth to try and accept it as solution instead. – Mauno Vähä Commented Jan 3, 2014 at 7:54
Add a ment  | 

2 Answers 2

Reset to default 1

It seems that this topic has generated some interests, I wan't to point out that I couldn't reproduce this problem after upgrading to play version 2.2.2. So I will be accepting this as a solution because it seems less hacky way to fix it.

Upgrade the Play Framework to 2.2.2

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744752319a4591670.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信