![]() You can find the code for this project in this repository on GitHub. This is just a small way that gulp can help us in the development of our applications. In this way, running the gulp command will wait for changes in the selected files to activate the minify-css task. You might be wondering - you’re already able to minify your files? Yes, by executing the gulp command in the terminal followed by the task name.īut running this command all the time is a bit annoying, isn’t it? We can create a method for observing changes to files in the styles folder. With the packages called, we will create the responsible task by minifying our files. In the end, our project will have this structure: In Gulpfile.jsĪt the beginning of the file, we make the calls of the packages that we will use. One will be called styles where our style files will stay, and another called dist where the minified files will go. We will create two folders in this repository too. This file will be responsible for our tasks. Very good, now with the dependencies installed in the project, let’s create a file called Gulpfile.js. We will also use a gulp plugin to minify CSS called gulp-clean-css, so install it in the project type: Once you have npm installed, in the base directory of your project we will install gulp using these commands: If you do not have it, you can download it here. Let’s startįor this tutorial, make sure you have the latest version of the npm package installed on your machine. Then put the minified ones in another folder. In this little tutorial, I will teach you how to create a task to minify all CSS files in your folder. In these tasks we load files that we want gulp to work on (modifying or not), then we return them to some return folder. We can create tasks that we would like to fulfill. Refreshing your browser when you save a file.Bundling and minifying libraries and stylesheets.Gulp is a JavaScript task runner that lets you automate tasks such as… In this article, I'm going to show a simple way to automatically minify your CSS files using gulp. By Vinicius Gularte How to minify your CSS with gulp
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |