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

Unable to disable comment preserving in uglifyjs plugin #324

Closed
dashed opened this issue Jun 24, 2014 · 16 comments
Closed

Unable to disable comment preserving in uglifyjs plugin #324

dashed opened this issue Jun 24, 2014 · 16 comments

Comments

@dashed
Copy link
Contributor

dashed commented Jun 24, 2014

Trying to do this: new webpack.optimize.UglifyJsPlugin({ comments: false })

Setting will be overwritten because of this:
https://github.com/webpack/webpack/blob/master/lib/optimize/UglifyJsPlugin.js#L79

Other reference:
https://github.com/mishoo/UglifyJS2/blob/master/lib/output.js#L62

@sokra
Copy link
Member

sokra commented Jun 24, 2014

Yes that's a bug...
Workaround: new webpack.optimize.UglifyJsPlugin({ output: {comments: false} })

@dashed
Copy link
Contributor Author

dashed commented Jun 24, 2014

Wow. Thanks for quick reply!

Workaround works.

@sokra sokra closed this as completed Jul 26, 2014
@drawveloper
Copy link

I have the inverse problem. Uglify is removing comments inside an HTML string and "comments":"all" is having no effect. Any idea when I'll be able to configure this properly?

@drawveloper
Copy link

Oops, apparently it was the html loader who was realizing there was minification going on and turned it's own minification processes on. I have manually disabled it and everything works.

@tleunen
Copy link

tleunen commented Jul 25, 2015

Found this post while searching for the same issue.

@sokra gave a workaround, which still works. Does it mean it's the right way now and it's not a bug?
Yep.. still a bug I guess :) https://github.com/webpack/webpack/blob/master/lib/optimize/UglifyJsPlugin.js#L95

@dashed
Copy link
Contributor Author

dashed commented Jul 25, 2015

@tleunen Should be resolved with #1298.

@WickyNilliams
Copy link

I'm still seeing this issue in latest version of webpack. @sokra's workaround does the trick

@NomNomCameron
Copy link

Can confirm that @sokra's workaround is still required for this

@sokra
Copy link
Member

sokra commented Nov 18, 2015

btw. it's intended that webpack preserves some comments. This is for legal reasons. By default comments with @license, @preserve or starting with /*! are preserved.

@dashed
Copy link
Contributor Author

dashed commented Nov 20, 2015

@WickyNilliams @NomNomCameron I tested using v1.12.6 on jquery source, and it seems to work just fine (with or without the workaround). The test I provided in my PR (#1298) didn't fail.

Are you sure you're using latest webpack version for both local and global?

@ccorcos
Copy link

ccorcos commented Jun 9, 2017

@sokra intersting! what legal reasons?

@dashed
Copy link
Contributor Author

dashed commented Jun 9, 2017

@ccorcos you typically want to preserve licenses which are usually at the top as a multi-line comment.

@ccorcos
Copy link

ccorcos commented Jun 9, 2017

That's what I'm reading here, but why is that?

@dashed
Copy link
Contributor Author

dashed commented Jun 9, 2017

@ccorcos some licenses require it.

@ccorcos
Copy link

ccorcos commented Jun 21, 2017

Look at this mess:

!function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l
  !*** ./~/lodash/lodash.js ***!
  \****************************/
function(e,t,n){(function(e,r){var o;(function(){function i(e,t){return e.set(t[0],t[1]),e}function a(e,t){return e.add(t),e}function
  !*** ./src/client/environment.ts ***!
  \***********************************/
function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=null},/*!************************************
  !*** ./src/client/components/Component.ts ***!
  \********************************************/
function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&func
  !*** ./~/react/react.js ***!
  \**************************/

So many comments that I dont need!

@chestozo
Copy link

chestozo commented Aug 8, 2023

Comments in bundle can result in issues like this one when wrong line number is reported in tools like Sentry
getsentry/sentry-javascript#2550 (comment)

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

8 participants