Gulp - Using existing minifiles and sourcemaps combined with unminified files and sourcemaps

We use the gulp process, which, like most people, compresses, uglify and concat JavaScript files into one "app.js" file. Some of the files we use are distributed through bower and already come pre-estimated with the source maps. Ideally, instead of re-minifying these files, we just use .min and .min.map directly. How do we apply this?

So our JavaScript.src files look like this:

'[FILE(S) TO BE UGLIFIED]',
'[FILE(S) ALREADY UGLIFIED]', // these also have map files
'[FILE(S) TO BE UGLIFIED]'

      

and we want them all in the same .min.js and app.min.js.map application.

That said, they are all copied to the dist directory, which is fine if we do something like uglify the first set of files, pipe to dist. Take the preexisting files already flushed + output from the first batch and complete them (and run again through the original cards) and then pipe again, then do the same for the last set.

The gulp plugins we already use to do all of this:

"gulp-concat": "2.4.1",
"gulp-uglify": "1.0.1",
"gulp-token-replace": "1.0.1",
"gulp-autoprefixer": "1.0.1",
"gulp-if": "1.2.5",
"gulp-sourcemaps": "1.2.2"

      

+3


source to share


1 answer


gulp sourcemaps

the plugin makes this very easy. Execute its function sourcemaps.init

right after gulp.src

with parameters {loadMaps: true}

and it checks for source maps with the same filename but the .map

extension at the end.



0


source







All Articles