Skip to content

Commit 17d44fa

Browse files
committed
don't run imagemin for preview
1 parent e0f47de commit 17d44fa

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

gulp.d/tasks/build.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const postcssImport = require('postcss-import')
1717
const postcssUrl = require('postcss-url')
1818
const postcssVar = require('postcss-custom-properties')
1919
const { Transform } = require('stream')
20-
const map = (transform) => new Transform({ objectMode: true, transform })
20+
const map = (transform = (file, enc, next) => next()) => new Transform({ objectMode: true, transform })
2121
const uglify = require('gulp-uglify')
2222
const vfs = require('vinyl-fs')
2323

@@ -106,14 +106,16 @@ module.exports = (src, dest, preview) => () => {
106106
vfs
107107
.src('img/**/*.{gif,ico,jpg,png,svg}', opts)
108108
.pipe(
109-
imagemin(
110-
[
111-
imagemin.gifsicle(),
112-
imagemin.jpegtran(),
113-
imagemin.optipng(),
114-
imagemin.svgo({ plugins: [{ removeViewBox: false }] }),
115-
].reduce((accum, it) => (it ? accum.concat(it) : accum), [])
116-
)
109+
preview
110+
? map()
111+
: imagemin(
112+
[
113+
imagemin.gifsicle(),
114+
imagemin.jpegtran(),
115+
imagemin.optipng(),
116+
imagemin.svgo({ plugins: [{ removeViewBox: false }] }),
117+
].reduce((accum, it) => (it ? accum.concat(it) : accum), [])
118+
)
117119
),
118120
vfs.src('helpers/*.js', opts),
119121
vfs.src('layouts/*.hbs', opts),

0 commit comments

Comments
 (0)