Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heredoc方式压缩问题 #68

Closed
zjgnlzq opened this issue Jun 26, 2015 · 1 comment
Closed

heredoc方式压缩问题 #68

zjgnlzq opened this issue Jun 26, 2015 · 1 comment

Comments

@zjgnlzq
Copy link

zjgnlzq commented Jun 26, 2015

我用heredoc方式写模板,如下:

function testDoc() {
/*!
<div>test</div>
*/
}

在用uglify压缩后,变成空函数了,如下:

function testDoc() {}

即使设置参数preserveComments: "some"也不行

@nuysoft
Copy link
Owner

nuysoft commented Jul 8, 2015

即使设置了 preserveComments: 'some',UglifyJS 会压缩掉函数末尾的注释。很多人已经讨论过这个问题,参考这里 https://github.com/mishoo/UglifyJS2/issues/88。

不过,通过在函数末尾加一行表达式(任何表达式),可以绕过这个规则。

function testDoc() {
    /*!
<div>test</div>
    */
    $.noop()
}

@nuysoft nuysoft closed this as completed Jul 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants