简体   繁体   English

SbtWeb:丑化traceur的输出

[英]SbtWeb: uglify the output of traceur

I'm using the SbtWeb traceur plugin to transpile my code in a Play Framework (sbt/scala) project. 我正在使用SbtWeb traceur插件在Play Framework(sbt / scala)项目中转换我的代码。 This gives me an ES5 resource at /main.js . 这在/main.js处提供了ES5资源。 I want to then uglify the result into /main.min.js . 然后,我想将结果丑化到/main.min.js I added the uglify plugin as well, and then tried to do the following: 我还添加了uglify插件,然后尝试执行以下操作:

pipelineStages := Seq(traceur, uglify)

Unfortunately this doesn't compile, as traceur is a TaskKey, but not of the correct type. 不幸的是,由于traceur是TaskKey,但类型不正确,因此无法编译。 How can I do this? 我怎样才能做到这一点?

Edit: It appears a closer-to-correct way to do this is like this: 编辑:它似乎是一种更接近正确的方法,例如:

pipelineStages in Assets := Seq(uglify)
includeFilter in uglify := GlobFilter("main.js")

However, I now get uglify errors that there are syntax errors in the Javascript. 但是,我现在得到uglify错误,表明Javascript中存在语法错误。 This has to be because uglify is trying to process the original ES6 sources, rather than the ES5 output of traceur. 这是因为uglify试图处理原始的ES6源,而不是traceur的ES5输出。 No idea how to get this to work yet. 尚不知道如何使它工作。

I encountered this problem too and couldn't find a solution with the plugin itself... 我也遇到了这个问题,无法使用插件本身找到解决方案...

I made a fork of sbt-traceur and update it. 我制作了sbt-traceur的叉子并对其进行了更新。 So now you can include traceur in the pipeline stage. 因此,现在您可以将Traceur纳入管道阶段。

Here it is: https://github.com/LuigiPeace/sbt-traceur 它在这里: https : //github.com/LuigiPeace/sbt-traceur

Hope this will help if you still use traceur. 希望如果您仍然使用Traceur,这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM