Gulp Preliminary Interview

Source: Internet
Author: User

1. To be in the node environment

2.

Global Install NPM Install GULP-G

Installing NPM Install Gulp--save-dev in the project

3. Installing plugins

  • Compilation of sass (Gulp-ruby-sass)
  • Automatically add CSS prefixes (gulp-autoprefixer)
  • Compress css (GULP-MINIFY-CSS)
  • JS code Check (gulp-jshint)
  • Merging JS files (gulp-concat)
  • Compression JS code (GULP-UGLIFY)
  • Compress picture (gulp-imagemin)
  • Auto Refresh page (gulp-livereload)
  • picture cache, only the picture is replaced by compression (Gulp-cache)
    var gulp = require (' Gulp '), Minifycss = require (' Gulp-minify-css '), concat = require (' Gulp-concat '), uglify = require (' gulp-uglify '), rename = require (' Gulp-renam E '), Del = require (' del '); Gulp.task (' Minifycss ', function () {return gulp.src (' css/*.css ')//compressed file. Pipe  (Concat (' main.css ')). Pipe (MINIFYCSS ())//Perform compression. Pipe (Gulp.dest (' minified/css ')); Output folder}); Gulp.task (' Minifyjs ', function () {return gulp.src (' js/*.js '). Pipe (Concat (' main.js '))//merge all js to Mai        N.js. Pipe (Gulp.dest (' Minified/js '))//Output main.js to folder. Pipe (rename ({suffix: '. Min '))//rename compressed file name  . Pipe (Uglify ())//compression. PIPE (Gulp.dest (' Minified/js '));    Output}); Gulp.task (' Clean ', function (CB) {del ([' Minified/css ', ' Minified/js '], CB)}); Gulp.task (' Default ', function () { Gulp.start (' minifycss ', ' minifyjs ');}); 
    The

    Runs Gulp in CMD.

  • Change Reminder (gulp-notify)
  • Purge File (del)

Installing these plugins requires running the following command:

NPM Install Gulp-ruby-sass gulp-autoprefixer gulp-minify-css gulp-jshint gulp-concat gulp-uglify gulp-imagemin Gulp-notify gulp-rename gulp-livereload gulp-cache del--save-dev

4. Create Gulpfile.js in the project root directory

Gulp Preliminary Interview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.