terinjokes / gulp-uglify

Minify files with UglifyJS
MIT License
1.23k stars 154 forks source link

gulp-uglify压缩匿名函数js无效 #353

Closed Bright0810 closed 5 years ago

Bright0810 commented 5 years ago

gulpfile.js

gulpfile

a.js

a

b.js

b

压缩后的a.js

dist_a

压缩后的b.js

dist_b

为什么b.js没有内容?????

terinjokes commented 5 years ago

b.js defines a FunctionStatement, but neither executes it nor assigns it to a variable. Therefore, it's dead code, and removed by UglifyJS.

On Mon, Jun 17, 2019, 2:37 AM 前端小菜鸟 notifications@github.com wrote:

gulpfile.js [image: gulpfile] https://user-images.githubusercontent.com/20697436/59594293-28c08080-9126-11e9-9eda-d05f083d50d3.png a.js [image: a] https://user-images.githubusercontent.com/20697436/59594469-76d58400-9126-11e9-957c-e69a3caa52c1.png b.js [image: b] https://user-images.githubusercontent.com/20697436/59594478-7b01a180-9126-11e9-9ae5-0e9a181cc710.png 压缩后的a.js [image: dist_a] https://user-images.githubusercontent.com/20697436/59594487-7fc65580-9126-11e9-942a-53619bc09868.png 压缩后的b.js [image: dist_b] https://user-images.githubusercontent.com/20697436/59594504-88b72700-9126-11e9-8ad6-38241fcfbba7.png

为什么b.js没有内容?????

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/terinjokes/gulp-uglify/issues/353?email_source=notifications&email_token=AACCYZNLNEIN5XSN7JWQTOTP25LNVA5CNFSM4HYU33O2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GZ2Y4ZQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AACCYZNJU5A25RPBEXEFWPLP25LNVANCNFSM4HYU33OQ .

Bright0810 commented 5 years ago

b.js定义了一个FunctionStatement,但既不执行它也不将它赋值给变量。因此,它是死代码,并由UglifyJS删除。 ... On Mon, Jun 17, 2019, 2:37 AM 前端小菜鸟 @.***> wrote: gulpfile.js [image: gulpfile] https://user-images.githubusercontent.com/20697436/59594293-28c08080-9126-11e9-9eda-d05f083d50d3.png a.js [image: a] https://user-images.githubusercontent.com/20697436/59594469-76d58400-9126-11e9-957c-e69a3caa52c1.png b.js [image: b] https://user-images.githubusercontent.com/20697436/59594478-7b01a180-9126-11e9-9ae5-0e9a181cc710.png 压缩后的a.js [image: dist_a] https://user-images.githubusercontent.com/20697436/59594487-7fc65580-9126-11e9-942a-53619bc09868.png 压缩后的b.js [image: dist_b] https://user-images.githubusercontent.com/20697436/59594504-88b72700-9126-11e9-8ad6-38241fcfbba7.png 为什么b.js没有内容????? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#353?email_source=notifications&email_token=AACCYZNLNEIN5XSN7JWQTOTP25LNVA5CNFSM4HYU33O2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GZ2Y4ZQ>, or mute the thread https://github.com/notifications/unsubscribe-auth/AACCYZNJU5A25RPBEXEFWPLP25LNVANCNFSM4HYU33OQ .

额 能配置不被UglifyJS删除吗