Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp uglify and save license

Tags:

gulp

I am trying to run Gulp and save license data like jQuery license info.

Gulp runs fine files are minimized but no license file: This is what I have in my Gulp file.

var gulp = require('gulp'),
saveLicense = ('uglify-save-license'),
uglify = require('gulp-uglify');

gulp.task('default', function () {
gulp.src('scripts/*.js', {
    output: {
        comments: saveLicense
    }
}
).pipe(uglify()).pipe(gulp.dest('publish_folder/scripts'));
console.log('Task Completed');
});

I'm very new to Gulp.

like image 764
Tim Avatar asked Feb 08 '23 15:02

Tim


1 Answers

The saveLicense object must be passed to the uglify plugin, not to gulp.src. Try this:

var gulp = require('gulp'),
    saveLicense = require('uglify-save-license'),
    uglify = require('gulp-uglify');

gulp.task('default', function () {
    gulp.src('scripts/*.js')
        .pipe(uglify({
            output: {
                comments: saveLicense
            }
        }))
        .pipe(gulp.dest('publish_folder/scripts'));

    console.log('Task Completed');
});

PS: Also I think you make a typo, you forget to write require when loading uglify-save-license plugin.

like image 114
franmartosr Avatar answered Mar 11 '23 00:03

franmartosr