nathanmac / laravel-elixir-imagemin

Laravel Elixir wrapper for ImageMin
MIT License
52 stars 14 forks source link

Path error #18

Closed rdehnhardt closed 5 years ago

rdehnhardt commented 8 years ago

// Config

elixir.config.publicPath = './../../../public';
elixir.config.assetsPath = 'assets';

elixir.config.images = {
    outputFolder: elixir.config.publicPath + '/build/back/images',
    folder: elixir.config.assetsPath + '/images'
};

// Debug

console.log('============================================');
console.log(config.get('assets.images.folder'));
console.log(config.images.folder);
console.log('============================================');
console.log(config.get('assets.images.outputFolder'));
console.log(config.images.outputFolder);
console.log('============================================');

// Result

============================================
assets/assets/images
assets/images
============================================
../../public/build/back/images
./../../../public/build/back/images
============================================

How can I fix this?

rdehnhardt commented 8 years ago

I try this and works

new elixir.Task('imagemin', function () {
        var paths = new elixir.GulpPaths()
            .src(config.images.folder)
            .output(config.images.outputFolder);

        return gulp.src(paths.src.path)
            .pipe(changed(paths.output.path))
            .pipe(imagemin(options))
            .on('error', function(e) {
                new elixir.Notification().error(e, 'ImageMin Failed!');
                this.emit('end');
            })
            .pipe(gulp.dest(paths.output.path))
            .pipe(new elixir.Notification('ImageMin Complete!'))
    }).watch(
        [
            config.images.folder + '/**/*.jpg',
            config.images.folder + '/**/*.jpeg',
            config.images.folder + '/**/*.svg',
            config.images.folder + '/**/*.gif',
            config.images.folder + '/**/*.png'
        ]
    );