vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 682 forks source link

How to use import modules to use in additionalTasks? #486

Closed york-xtrem closed 6 years ago

york-xtrem commented 7 years ago

For example "gulp-imagemin":

// task-config.js
additionalTasks: {
    initialize(gulp, PATH_CONFIG, TASK_CONFIG) {
      gulp.task('compressImages', function () {
        return gulp.src(PATH_CONFIG.images.src)
          .pipe($.imagemin({
            progressive: true,
            interlaced: true
          }))
          .pipe(gulp.dest(PATH_CONFIG.dest + PATH_CONFIG.images.dest)));
      })
    },
    development: {
      prebuild: [],
      postbuild: []
    },
    production: {
      prebuild: [],
      postbuild: ['compressImages']
    }
  }
dillonbailey commented 6 years ago

@york-xtrem not sure if this will be useful, but...take a look at the top of this GIST

https://gist.github.com/dillonbailey/c06b1ee88ab1432435515c65840daf74

  1. yarn add gulp-imagemin -D
  2. Declare const imagemin = require('gulp-imagemin'); at the top of your task-config.js
  3. Should all work

Not sure why you are referencing $ in your snippet but you would need to import that as well if imagemin needs it.

york-xtrem commented 6 years ago

Thanks @dillonbailey ! I will try that.

benjtinsley commented 6 years ago

@york-xtrem did the solution provided by @dillonbailey suffice? i will close this out unless there are further issues you may be having