I am using gulp.
I would like to having one or multiple JS files (say jQuery) to combine them in one, minify it, and write it to a distribution folder.
This is how I do it:
minifyJS(['/js/myModule.file1.js',
'/js/myModule.file2.js'], '/dist/js', 'myModule')
the function:
function minifyJS(sourceFiles, destinationFolder, filenameRoot) {
return gulp.src(sourceFiles)
.pipe(plumber())
// .pipe(sourcemaps.init()) here ???
.pipe(concat(filenameRoot + '.js'))
.pipe(sourcemaps.init()) // or here ???
.pipe(gulp.dest(destinationFolder)) // save .js
.pipe(uglify({ preserveComments: 'license' }))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest(destinationFolder)) // save .min.js
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest(destinationFolder)) // save .map
}
What I am not sure about is the sourcemaps.init()
location...
Should I create multiple (2 in my case) map files (that would be nice if is supported by browsers) or only one (/maps/myModule.map)?