![npm minify npm minify](http://taswar.zeytinsoft.com/wp-content/uploads/2015/02/Grunt1.png)
![npm minify npm minify](https://node-minify.2clics.net/assets/img/cli.145106ae.png)
NPM MINIFY INSTALL
Now let’s install gulp-imagemin by typing npm install -save-dev gulp-imagemin and again you'll get something like this back: added 232 packages from 97 contributors and audited 10669 packages in 39.103s found 0 vulnerabilities.You can check your Gulp version by typing gulp -v in your terminal and you'll get something similar to this: CLI version 2.0.1 Local version 4.0.0.Again, be patient as installing Gulp might take a minute but you’ll eventually end up with something like this: added 318 packages from 218 contributors and audited 6376 packages in 49.362s found 0 vulnerabilities.If you want to know what the -save-dev flag does, check out this Stack Overflow post. First, type npm install -save-dev gulp in your terminal.Once Node & npm have been installed, we can now install Gulp & gulp-imagemin by following these steps: This is so I can provide an example, as I have previously installed all of this in my current project directory.ĪDVERTISEMENT Installing Gulp & gulp-imagemin You’ll notice that this file was created in a different directory than the one I started with.
NPM MINIFY SERIES
You'll be asked a series of questions but if you don't want to answer them you don't have to, just hit enter until you see Is this OK? (yes), then hit Enter one last time and you'll be finished with this section. We do this by using the command npm init (find out more about package.json here). Next we need to create a package.json file for our project.You can check the version of npm by typing npm -v in your terminal. Once Node.js is installed, you'll have npm installed as well because it comes bundled with Node.It could take a few minutes so +be patient. If you get nothing back or an error, simply download and install Node from here.If you do, you'll get something back like v8.9.3 First, enter node -v within your terminal to check and see if you have the Node installed.If you already have Node & npm installed, feel free to skip down to the Installing Gulp & gulp-imagemin Section. Once you have your project directory established it’s time to start installing everything we’ll need.Īlright, now that our directory is up and running let’s start installing our dependencies. Here’s how my project structure looks in my terminal:Īnd here’s how my project file structure looks in the explorer inside VS Code:Īs you can see I have a separate directory for my base files and the minified files. If you’re using VS Code you can find the built in terminal by hitting ctrl + ` (tilde). Start by opening up your text editor of choice and creating a directory for your project or if you have an existing directory navigate to that directory in your terminal and skip down to the Installing Node & npm Section. You can find gulp-imagemin here.Īlright, now that explanations are out of the way let’s get to the fun parts :D Project File Structure Using this package we'll be able to automatically reduce the size of our images every time a save occurs. gulp-imagemin is one of those awesome packages I mentioned earlier.Just think of npm as a giant storage area for awesome packages/utilities to help developers.
![npm minify npm minify](https://www.scriptverse.academy/img/tutorials/grunt-css-minify.png)
NPM MINIFY SOFTWARE
It is a package manager for JavaScript and "the world's largest software registry".
![npm minify npm minify](https://blog.logrocket.com/wp-content/uploads/2019/06/terser-uglify-babel-minify-webpack-npm-trends.png)
Minification, or minifying as I like to call it, is the act or process of removing unnecessary parts of source code to reduce size.If you don’t know what all of these words mean, fear not! I have some relevant and important links/descriptions below to help bring you up to speed.
NPM MINIFY HOW TO
So today, I’m going to teach you how to use Gulp and an npm package called gulp-imagemin to reduce the size of your images on the fly. Images are great way to help tell stories and emphasize critical parts of our lives.īut if you’re like me you know that having a large image can seriously impact the performance of your site/app. You would be hard pressed to find a single page or application that doesn’t contain at least one image in some form or another. Images are everywhere across the internet.