File tree Expand file tree Collapse file tree
test/configCases/plugins/uglifyjs-plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ UglifyJsPlugin.prototype.apply = function(compiler) {
9292 ast . mangle_names ( options . mangle || { } ) ;
9393 }
9494 var output = { } ;
95- output . comments = options . comments || / ^ \* * ! | @ p r e s e r v e | @ l i c e n s e / ;
95+ output . comments = Object . prototype . hasOwnProperty . call ( options , "comments" ) ? options . comments : / ^ \* * ! | @ p r e s e r v e | @ l i c e n s e / ;
9696 output . beautify = options . beautify ;
9797 for ( var k in options . output ) {
9898 output [ k ] = options . output [ k ] ;
Original file line number Diff line number Diff line change 1+ it ( "should contain no comments in out chunk" , function ( ) {
2+ var fs = require ( "fs" ) ;
3+ var source = fs . readFileSync ( __filename , "utf-8" ) ;
4+ source . should . not . match ( / [ ^ \" ] c o m m e n t s h o u l d b e s t r i p p e d t e s t \. 1 [ ^ \" ] / ) ;
5+ source . should . not . match ( / [ ^ \" ] c o m m e n t s h o u l d b e s t r i p p e d t e s t \. 2 [ ^ \" ] / ) ;
6+ source . should . not . match ( / [ ^ \" ] c o m m e n t s h o u l d b e s t r i p p e d t e s t \. 3 [ ^ \" ] / ) ;
7+ } ) ;
8+
9+ it ( "should contain comments in vendors chunk" , function ( ) {
10+ var fs = require ( "fs" ) ,
11+ path = require ( "path" ) ;
12+ var source = fs . readFileSync ( path . join ( __dirname , "vendors.js" ) , "utf-8" ) ;
13+ source . should . containEql ( "comment should not be stripped vendors.1" ) ;
14+ source . should . containEql ( "// comment should not be stripped vendors.2" ) ;
15+ source . should . containEql ( " * comment should not be stripped vendors.3" ) ;
16+ } ) ;
17+
18+
19+ require . include ( "./test.js" ) ;
Original file line number Diff line number Diff line change 1+ /** @preserve comment should be stripped test.1 */
2+
3+ var foo = { } ;
4+
5+ // comment should be stripped test.2
6+
7+ /**
8+ * comment should be stripped test.3
9+ */
10+
11+ module . exports = foo ;
Original file line number Diff line number Diff line change 1+ /** @preserve comment should not be stripped vendors.1 */
2+
3+ var bar = { } ;
4+
5+ // comment should not be stripped vendors.2
6+
7+ /**
8+ * comment should not be stripped vendors.3
9+ */
10+
11+ module . exports = bar ;
Original file line number Diff line number Diff line change 1+ var webpack = require ( "../../../../" ) ;
2+ module . exports = {
3+ node : {
4+ __dirname : false ,
5+ __filename : false
6+ } ,
7+ entry : {
8+ bundle0 : [ "./index.js" ] ,
9+ vendors : [ "./vendors.js" ]
10+ } ,
11+ output : {
12+ filename : "[name].js"
13+ } ,
14+ plugins : [
15+ new webpack . optimize . UglifyJsPlugin ( {
16+ comments : false ,
17+ exclude : [ "vendors.js" ]
18+ } )
19+ ]
20+ } ;
You can’t perform that action at this time.
0 commit comments