gulp-community / gulp-concat

Streaming concat middleware for gulp
MIT License
792 stars 127 forks source link

Concat to a single line of JS #126

Closed ttomdewit closed 7 years ago

ttomdewit commented 7 years ago

Hi all,

First of all thank you for creating and maintaining this package, it's been very helpful thus far!

Unfortunately I've been unable to get the following to work with the documentation provided: my current Gulp task collects all my JS files and puts them together with concat, then uglifies my code. See task:

gulp.task('scripts', function() {
    return gulp.src(['node_modules/jquery/dist/jquery.js', 'assets/js/vendor/*.js', 'assets/js/**/*.js', '!assets/js/head.js', '!assets/js/vendor/modernizr.js'])
    .pipe($.concat('main.js'))
    .pipe($.rename({ suffix: '.min' }))
    .pipe($.uglify())
    .pipe(gulp.dest('assets/dist/js'))
    .pipe(browserSync.stream())
    .pipe($.notify({ title: 'Scripts', message: 'Task completed', onLast: true }))
});

The output is close to what I want. At the moment it's creating a main.min.js file as you'd expect, only it creates 3 lines. I'd like it to put everything on 1 line.

I searched the issues for newLine and didn't find what I was looking for. Any help is greatly appreciated.

Other information: $ npm -v is at 3.10.3 $ node -v is at v6.7.0

If you need anything else, let me know.

ttomdewit commented 7 years ago

My friend @jegtnes took a plunge and looked into my issue and apparently UglifyJS limits line length to 32K characters. This issue has nothing to do with gulp-concat.

@ttomdewit @_lukewh Aha! Got to the bottom of it. UglifyJS limits the maximum length of a line to 32K characters by default.

Read Tweet

@ttomdewit @_lukewh So nothing to do with gulp-concat :) There’s an UglifyJS option to override it—but I’m sure it’s there for a good reason

Read Tweet