fix gulp scripts pipeline failing on second run because of how sourcemaps are cleared

This commit is contained in:
Jakob Schrettenbrunner 2018-05-31 18:26:34 +02:00
parent c58ef1f8a8
commit e808919c5c

View file

@ -18,7 +18,7 @@ const argv = require('yargs')
const paths = { const paths = {
manifest: './public/assets', manifest: './public/assets',
assets: './public/assets/{css,scripts}/*.{css,css.map,js,js.map}', assets: './public/assets/{css,scripts}/*.{css,js,map}',
styles: { styles: {
src: './resources/assets/styles/main.css', src: './resources/assets/styles/main.css',
dest: './public/assets/css', dest: './public/assets/css',
@ -30,11 +30,6 @@ const paths = {
}, },
}; };
const clearSourcemaps = through.obj(function (file, enc, cb) {
if (!/\.map$/.test(file.path)) this.push(file);
cb();
});
/** /**
* Build un-compiled CSS into a minified version. * Build un-compiled CSS into a minified version.
*/ */
@ -63,7 +58,10 @@ function styles() {
function scripts() { function scripts() {
return webpackStream(webpackConfig) return webpackStream(webpackConfig)
.pipe(sourcemaps.init({loadMaps: true})) .pipe(sourcemaps.init({loadMaps: true}))
.pipe(clearSourcemaps) .pipe(through.obj(function (file, enc, cb) { // Remove Souremaps
if (!/\.map$/.test(file.path)) this.push(file);
cb();
}))
.pipe(babel()) .pipe(babel())
.pipe(gulpif(argv.production, uglify())) .pipe(gulpif(argv.production, uglify()))
.pipe(concat('bundle.js')) .pipe(concat('bundle.js'))