nathanmac / laravel-elixir-imagemin Goto Github PK
View Code? Open in Web Editor NEWLaravel Elixir wrapper for ImageMin
License: MIT License
Laravel Elixir wrapper for ImageMin
License: MIT License
Hi,
I have just installed this into my laravel project and I have the setup as follows:
process.env.DISABLE_NOTIFIER = true;
var elixir = require('laravel-elixir');
// var BrowserSync = require('laravel-elixir-browsersync');
require('laravel-elixir-imagemin');
require('laravel-elixir-uglify');
require('laravel-elixir-browser-sync-simple');
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic Gulp tasks
| for your Laravel application. By default, we are compiling the Sass
| file for our application, as well as publishing vendor resources.
|
*/
elixir(function(mix) {
mix.sass('app.scss', null, { includePaths: ['resources/assets/sass/partials','resources/assets/sass/bourbon', 'resources/assets/sass/fontawesome','resources/assets/sass/partials/css3'] })
.browserSync({
proxy: 'synergycamps.dev',
logPrefix : "Laravel Elixir BrowserSync",
logConnections : false,
reloadOnRestart : false,
notify : false
});
mix.scripts([
'app.js'
]).uglify('**/*.js', 'public/js', {
mangle: true,
suffix: '.min'
});
mix.imagemin("IMG_5877.jpg");
});
When I do gulp watch
I get the message title output and no images are changed at all. In my /resources/img/ folder I have got the image but nothing is being touched.
Is this a bug?
Decided to try this on a Laravel 5.2 project. I'm getting the following error:
Error: Cannot find module 'laravel-elixir-imagemin'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\Users\Robert\MyWebs\Sites\biospex\gulpfile.js:3:1)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
Right now, my gulp file is stripped down to the most basic code:
var elixir = require('laravel-elixir');
require('laravel-elixir-imagemin');
Any ideas?
Hello, I have added:
elixir.config.images = {
folder: './addons/default/themes/defeault/gittheme/img/',
outputFolder: './assets/build/img/'
};
Later in the code: mix.imagemin(), But I get:
[00:03:56] Starting 'imagemin'...
[00:03:56] gulp-imagemin: Minified 0 images
[00:03:56] Finished 'imagemin' after 11 ms
What I could be doing wrong?
First, congratulations on the module it is very interesting.
I believe this would be an improvement ...
For example, normally systems have different directories eg:
and their images would be there.
//as we have today
config.images = _.extend({
folder: 'images', //It would be interesting to place an object containing several directories recursively
outputFolder: 'images'
}, config.images || {});
elixir.json
//possible implementation
{
"images": {
"frontend-test1": {
"folder": ["frontend/images/folder1", "frontend/images/folder2"], // find by resources
"outputFolder": "images/frontend/folder1", "images/frontend/folder2" //export into public/
},
"frontend-test2": {
"folder": ["frontend/images/folder3", "frontend/images/folder4"], // find by resources
"outputFolder": "images/frontend/folderx" //export into public/
}
"backend-test1": {
"folder": ["backend/images/folder1", "backend/images/folder2"], // find by resources
"outputFolder": "images/backend/folderx" //export into public/
}
"backend-test2": {
"folder": ["backend/images/folder3", "backend/images/folder4"], // find by resources
"outputFolder": "images/backend/foldery" //export into public/
}
}
}
Today, I have only one option to put the images.
It would be interesting and I believe that increase the functionality of it, with the possibility of adding different directories of both origin and destination.
Sincerely, and success!
Just like every other gulp function has, this one needs the ability to ignore a path by pre-pending an !
to the path.
If you're not going to bring back the "old syntax", you'll need to incorporate this into the config lines somehow.
Please bring back the ability to use what you refer to as "old syntax".. i.e. the ability to override and select multiple files within the mix function itself.
The rest of elixir still works like that so I don't understand why you removed it.
It seems elixir structure has changed for Laravel 5 and utilities is no more an helper.
I was able to make it work again by changing the utilities var definition in index.js, line 8
var utilities = require('laravel-elixir/ingredients/commands/Utilities');
https://github.com/laravel/elixir/releases/tag/3.0.0
Let me know if you need a PR
Hello,
I am using: Laravel 5.1 and Elixir 2.3.13. I am getting an error when I run the imagemin task. I am using the same config as the last example (all of the other examples gives me the same error as well, even if I do not pass any params):
elixir(function(mix) {
mix.imagemin(
"./resources/assets/img",
"public/img",
{ optimizationLevel: 3, progressive: true, interlaced: true }
);
});
And it fails:
/Users/superkalo/Sites/one-studio/node_modules/laravel-elixir-imagemin/index.js:35
new elixir.Task('imagemin', function () {
^
TypeError: undefined is not a function
at Object.imagemin (/Users/superkalo/Sites/one-studio/node_modules/laravel-elixir-imagemin/index.js:35:15)
at /Users/superkalo/Sites/one-studio/gulpfile.js:93:10
at Elixir (/Users/superkalo/Sites/one-studio/node_modules/laravel-elixir/index.js:3:5)
at Object.<anonymous> (/Users/superkalo/Sites/one-studio/gulpfile.js:25:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
Any suggestions why?
Thanks in Advance!
I'm getting the following error. BinWrapper seems to be trying to access process.env.PATH
which isn't set. Any ideas why?
TypeError: Cannot call method 'split' of undefined
at new BinWrapper (/../node_modules/laravel-elixir-imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin/node_modules/bin-wrapper/index.js:26:30)
at Object.<anonymous> (/../node_modules/laravel-elixir-imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin/lib/index.js:18:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> /../node_modules/laravel-elixir-imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin/index.js:3:11)
at Module._compile (module.js:456:26)
When using laravel-elixir-imagemin 0.2.3 with imagemin-svgo 5.2.0 the below error occurs:
/Users/brian/Sites/ddos/node_modules/is-svg/index.js:8
var charCode = isBuf ? buf[i] : buf.charCodeAt(i);
^
TypeError: Cannot read property 'charCodeAt' of undefined
at isBinary (/Users/brian/Sites/ddos/node_modules/is-svg/index.js:8:38)
at module.exports (/Users/brian/Sites/ddos/node_modules/is-svg/index.js:19:10)
at buf (/Users/brian/Sites/ddos/node_modules/imagemin-svgo/index.js:8:7)
at Imagemin.use (/Users/brian/Sites/ddos/node_modules/imagemin/index.js:63:51)
at DestroyableTransform.through.obj.percent (/Users/brian/Sites/ddos/node_modules/gulp-imagemin/index.js:47:5)
at DestroyableTransform._transform (/Users/brian/Sites/ddos/node_modules/through2-concurrent/through2-concurrent.js:30:15)
at DestroyableTransform.Transform._read (/Users/brian/Sites/ddos/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (/Users/brian/Sites/ddos/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83)
at doWrite (/Users/brian/Sites/ddos/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:313:64)
at writeOrBuffer (/Users/brian/Sites/ddos/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:302:5)
If I downgrade imagemin-svgo to ^4.2.0 everything works.
When your project directory has spaces in it the installation will fail. I also get zlib errors.
// 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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.