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

uglify 和 cssmin 对特殊注释的处理 #70

Closed
meowtec opened this issue Jan 15, 2015 · 2 comments
Closed

uglify 和 cssmin 对特殊注释的处理 #70

meowtec opened this issue Jan 15, 2015 · 2 comments

Comments

@meowtec
Copy link

meowtec commented Jan 15, 2015

很多开源类库习惯在代码中使用注释的方式标注版权信息,比如:

/*! 
  jQuery v1.11.2 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license 
  (special comments)
*/

/* normal comments */

通常版权注释会以 /*! 开头,或者包含 @license@preserve
如果开发者希望在自己压缩后的代码中保留版权信息,或者在项目中使用了保留版权信息的第三方开源代码,spm 打包压缩之后,这些特殊注释应该被保留在压缩后的代码中,而不应该删除。

目前 spm 的处理方式是:CSS 压缩时默认保留特殊注释,而 JS 压缩时则会删除所有注释,分别是 gulp-cssmin 和 gulp-uglify 的默认处理方式。

  • gulp-uglify 选项:删除所有注释(默认)、保留特殊注释、保留所有注释、回调函数
  • gulp-cssmin 选项:保留特殊注释(默认)、删除特殊注释、保留第一条特殊注释

spm-build 可以提供一个参数,控制是否删除特殊注释,默认为保留特殊注释。

@sorrycc
Copy link
Member

sorrycc commented Jan 15, 2015

可以在 package.json 里配的,比如:

{
  "spm": {
    "cssmin": {},
    "uglify": {}
  }
}

@meowtec
Copy link
Author

meowtec commented Jan 15, 2015

嗯,一开始没弄明白 args.uglify 的意思

@sorrycc sorrycc closed this as completed Jan 19, 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