I am creating 3 mini-packages for my application. I have 2 tasks to do this, reduce and stratify. Minify is package dependent. If I run minify, both tasks run without errors. Packages are created, but mini files are not. If I remove the package dependency, I can run minify on my own and the thumbnail files will be created successfully. It makes me think, maybe files are used when the trigger of the minimization task (since the package is not finished yet?). How to make it wait until the files are completely ready? Can I stream a stream? Or maybe combine them into one task? The reason that they are currently not a single task is that they output 2 files per bundle (unminified and minipack).
var outFolder = __dirname + '\\Scripts\\dist'; var appBundles = [ { scripts: ['Scripts/Common/**/*.js'], output: 'eStore.common.js' }, { scripts: ['Scripts/Checkout/**/*.js'], output: 'eStore.checkout.js' }, { scripts: ['Scripts/ProductDetail/**/*.js'], output: 'eStore.product.js' } ]; gulp.task('bundle', bundle); gulp.task('minify', ['bundle'], minify); // this one doesn't work gulp.task('minifyOnly', minify); // this one works function bundle() { appBundles.forEach(function (appBundle) { gulp.src(appBundle.scripts) .pipe(concat(appBundle.output)) .pipe(sourcemaps.init()) .pipe(sourcemaps.write(outFolder + '\\maps')) .pipe(gulp.dest(outFolder)) .on('error', errorHandler); }); } function minify() { appBundles.forEach(function(appBundle) { var bundleSrc = outFolder + '\\' + appBundle.output; gulp.src(bundleSrc) .pipe(rename({ extname: '.min.js' })) .pipe(uglify()) .pipe(gulp.dest(outFolder)) .on('error', errorHandler); }); }
source share